How to generate full APK file including dynamic feature module

孤街醉人 提交于 2019-12-18 06:09:28

问题


My project has dynamic feature module and I would like to generate debug or release APK including the dynamic feature. Currently I can get only base APK file.

Basically I would generate an APK file like normal application. But I couldn't do with dynamic feature. Yes, I know dynamic feature will work based on AAB.

Is there any ways to make a normal(base + all modules) APK file?. Please help on this.

Thanks


回答1:


You can specify if your on demand module needs to be included in the universal APK that is usually generated for older devices, and then you can use bundletool to generate an Universal APK from the App Bundle:.

In this particular case, you can use something like:

bundletool build-apks --bundle <bundle_file> --output <APKS file> --ks <key_store> --key-pass <jks password> --ks-key-alias <key_alias> --ks-pass <key password> --overwrite --mode=universal

The key point is to include the --mode=universal this instruct bundletool to generate an Universal APK that will include all modules that have <dist:fusing dist:include="true"/> in the manifest.

In a similar way, when you run your project from Android Studio on a device, using the default configuration for Run (Deploy = Default APK) it includes all of your on demand modules.
Instead, when you run the application from Studio using the Run configuration (Deploy = APK from AppBundle) you can pick and choose which modules are installed.

However, in both cases, you cannot test on demand module downloads if you don't go through the Play store.

Update June 2019

Google introduced at I/O Internal App Sharing that allows to allow testing easily your App Bundles and APKs, including debug builds:

With internal app sharing, you can quickly share an app bundle or APK with your internal team and testers by uploading an APK or app bundle on the internal app sharing upload page.




回答2:


I don't see it documented anywhere, but the Android Gradle build tools includes tasks to extract the universal APK for you. You can use something similar to:

./gradlew :yourmodule:packageDebugUniversalApk

Under the hood it uses bundletool and does essentially the same thing as the other answer, but it's nice to be able to do it from Gradle.



来源:https://stackoverflow.com/questions/54844007/how-to-generate-full-apk-file-including-dynamic-feature-module

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!