1

我通过“com.android.dynamic-feature”设置了菜单模块。当我编码并由 android studio 运行时,一切正常。当通过 Build -> Build APK(s) 打包 apk 时,当我在模块中开始活动时,它会崩溃 Class Not Found。注意:活动路径是正确的,我猜我的模块没有附加到应用程序中

  1. 清单模块:
    <dist:module
        dist:instant="false"
        dist:onDemand="false"
        dist:title="">
        <dist:delivery>
            <dist:install-time />
        </dist:delivery>
        <dist:fusing dist:include="true" />
    </dist:module>
  1. 模块等级
apply plugin: 'com.android.dynamic-feature'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'
apply from: '../shared_dependencies.gradle'

这里有什么错误吗?谢谢

4

2 回答 2

1

如果您使用<dist:fusing dist:include="true" />并签署​​您的应用程序,APK它仍然不包含在您的APK. dynamic-feature仅与AAB格式一起使用。

如果您仍想使用格式,APK则必须使用bundle-tooluniversal APKAAB

https://developer.android.com/studio/command-line/bundletool

于 2020-11-02T07:45:25.107 回答
0

构建具有动态功能模块的 Android 项目将始终在模拟器上运行,因为在 Google Play 上没有交付系统。Build -> Build Bundle(s)/APK(s)->Build Bundle(s)当你使用功能模块时,你也应该使用选项。

在您的主模块的build.gradle文件中,您需要设置dynamicFeatures,例如:

android {
...
  dynamicFeatures = [
        ':module1',
        ':module2',
        ':module3'
   ]
...
}

在动态功能模块的build.gradle文件中,您需要对主模块的依赖:

dependencies {
   implementation project(':app')
}
于 2020-03-13T09:59:39.993 回答