How to generate full APK file including dynamic feature module

后端 未结 3 1790
一生所求
一生所求 2020-12-09 10:57

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.

Basica

3条回答
  •  悲&欢浪女
    2020-12-09 11:42

    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  --output  --ks  --key-pass  --ks-key-alias  --ks-pass  --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 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.

    Note (November 2020)

    As reported in another answer below, the Android Gradle Plugin includes a couple of undocumented tasks that can be used to generate Debug and unsigned Release universal APKs of your application.

    The task related to the Debug version can be a quick alternative if you just need this type of build:

    ./gradlew :app:packageDebugUniversalApk
    

    This task will generate (by default) app/build/outputs/universal_apk/debug/app-debug-universal.apk.

    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.

提交回复
热议问题