I use dynamic feature module in my app and here is my App
class -
@HiltAndroidApp
class DogApp : SplitCompatApplication() {
override fun attachBaseContext(base: Context?) {
super.attachBaseContext(base)
SplitCompat.install(this)
}
}
Here is my MainActivity
-
private var sessionId: Int = 0
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
fetchModules()
}
private fun fetchModules() {
val splitInstallManager = SplitInstallManagerFactory.create(this)
val request = SplitInstallRequest
.newBuilder()
.addModule("dogProfile")
.build()
val listener =
SplitInstallStateUpdatedListener { splitInstallSessionState ->
if (splitInstallSessionState.sessionId() == sessionId) {
when (splitInstallSessionState.status()) {
SplitInstallSessionStatus.INSTALLED -> {
Log.e("hi", "Installed")
}
SplitInstallSessionStatus.DOWNLOADING -> {
val totalBytes = splitInstallSessionState.totalBytesToDownload()
val progress = splitInstallSessionState.bytesDownloaded()
Log.e("hi", "Downloading$totalBytes...$progress")
}
SplitInstallSessionStatus.INSTALLING -> {
Log.e("hi", "Installing")
}
}
}
}
splitInstallManager.registerListener(listener)
splitInstallManager.startInstall(request)
.addOnFailureListener { e -> Log.e("hi", "Exception: $e") }
.addOnSuccessListener {
Log.e("hi", "Success")
sessionId = it
val navHostFragment =
supportFragmentManager.findFragmentById(R.id.nav_host_fragment) as NavHostFragment
navHostFragment.navController.navigate(R.id.homeView)
}
}
When I build the apk and run on my device/emulator, I see "Installing Module" that stays forever and I see the logs -
Installed
Success
Here is the screen I see forever -
What is the mistake I am doing?
Did you use navigation
2.3.2
? I found there is an issue after this change. Rollback to2.3.1
or use your own progress UI instead ofDefaultProgressFragment
will fix this issue.