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?
from Android dynamic feature struck at installing view although it says it is installed
No comments:
Post a Comment