android - Android动态功能卡在安装视图虽然它说它已安装
问题描述
我在我的应用程序中使用动态功能模块,这是我的App
课程 -
@HiltAndroidApp
class DogApp : SplitCompatApplication() {
override fun attachBaseContext(base: Context?) {
super.attachBaseContext(base)
SplitCompat.install(this)
}
}
这是我的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)
}
}
当我构建 apk 并在我的设备/模拟器上运行时,我看到永远存在的“安装模块”并且我看到了日志 -
Installed
Success
这是我永远看到的屏幕-
我在做什么错误?
解决方案
你用导航了2.3.2
吗?我发现此更改后存在问题。回滚到2.3.1
或使用您自己的进度 UI 而不是DefaultProgressFragment
将解决此问题。
推荐阅读
- kubernetes - Kubernetes - 如何在 .yml 文件中执行命令
- r - 将数据框从 R 导出到 .csv 时小数点符号消失
- firebase - 如何在没有 Firebase 管理员的情况下使用 Firebase Firestore 模拟器
- python - 线程函数响应延迟
- sql - SQL 为什么我收到无效标识符错误?
- r-exams - 黑板不导入 Blackboard.zip
- python - 在 VScode 中跟踪 python 警告
- typescript - 如何根据类方法返回类型声明参数类型?
- reactjs - 如何避免来自 Apollo useMutation 钩子的解构突变?
- angular - 有没有办法在 Angular 中设置模块级 css?