android - Android 动态功能:错误 -2 模块不可用
问题描述
我一直在调试一整天都没有结果,我已经关注了每个文档和谷歌代码实验室并将捆绑包上传到内部测试并且错误仍然存在:模块不可用,下面是我的实现:
模块 AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:dist="http://schemas.android.com/apk/distribution"
package="com.appshive.shop"
>
<dist:module
dist:instant="false"
dist:title="@string/measure">
<dist:delivery>
<dist:on-demand />
</dist:delivery>
<dist:fusing dist:include="true" />
</dist:module>
</manifest>
模块 build.gradle:
plugins {
id 'com.android.dynamic-feature'
id 'kotlin-android'
id 'kotlin-kapt'
id 'kotlin-android-extensions'
}
android {
compileSdkVersion 30
buildToolsVersion "30.0.2"
defaultConfig {
minSdkVersion 22
targetSdkVersion 30
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
}
}
并且该模块具有片段以及它们的一些依赖项。
在基础应用 Android Manifest 中:
我添加了这个
dynamicFeatures = [':measure']
android:name=".core.ShopApplication"
我在 build.gradle 中的应用程序 ID 是:com.appshive.ecommerce
我的应用程序类扩展了 SplitCompatApplication
class ShopApplication: SplitCompatApplication(){
override fun onCreate() {
super.onCreate()
Timber.plant(DebugTree())
SplitCompat.install(this)
startKoin {
androidContext(this@ShopApplication)
modules(listOf(appModule, repoModule))
}
}
我在所有项目中只有一项活动:主要活动,它包含
private lateinit var manager: SplitInstallManager
在 onCreate 我初始化它: manager = SplitInstallManagerFactory.create(this)
我正在检查模块是否可用我正在打开其他片段:
val request = SplitInstallRequest.newBuilder()
.addModule(name)
.build()
manager.startInstall(request).addOnSuccessListener {
makeToast("Successss")
}.addOnFailureListener { e->
makeToast(e.message.toString()+" as")
}
我正在向经理注册听众:
override fun onPause() {
manager.unregisterListener(listener)
super.onPause()
}
override fun onResume() {
manager.registerListener(listener)
super.onResume()
}
就是这样,然后我使用我的密钥生成签名包并将其上传到内部测试,然后我将它安装在我的手机上,然后发生错误:错误 -2 模块不可用
我已经尝试了互联网上的所有方法,但没有运气我不知道我错过了什么。是因为捆绑签名还是因为打包?
当我更改模块以安装时间模块时,它就像一个魅力。
解决方案
当我在开发这个功能时,我只使用 Playstore 的内部测试功能进行测试。
后来我才知道还有另一种方法可以使用名为Bundle Tool的工具在本地进行。
您可以从给定的链接下载它。下载 Bundle Tool 文件后,您需要使用它生成 apk。
bundletool build-apks
--bundle=app/build/outputs/bundle/debug/bundle.aab
--output=my_app.apks
PS。当我在我的应用程序中执行此功能时,我使用 Java 代码开发它,但我 100% 确信它也可以与 kotlin 代码一起使用。
推荐阅读
- html - CSS:标题全屏宽度,其他内容未包装
- mysql - Mysql Query Browser - 在其上设置和添加连接
- action - Google 操作不会更新智能设备上的调用
- kubernetes - Kubernetes 中如何使用 Istio Ingress 转发 RabbitMQ 的 STOMP 协议?
- maven - Maven - 能够运行一组测试但不能运行单个测试
- php - 绕过用户输入从 PFX 证书转换为单独的 PEM 文件
- sql - 按年龄范围(“30 岁以下”-“30 - 39”...)按客户数量分组,按他们使用 Oracle SQL 购买的产品分组
- android - Android Studio 4.2 分析代码需要很长时间
- windows - Npsql 在 Windows 托管的 postgres 时间刻度服务器上超时二进制导入(COPY 二进制)
- r - 如何根据数字天值添加月份列