androidandroid-gradle-pluginandroid-app-bundledynamic-feature

Generating APK with all dynamic features


I have added a dynamic feature module to my project and everything works fine when trying on emulator or direct run on a device (using the run button) but when I try to generate a APK using command line (:app:assembleRelease) the dynamic feature modules wont be included in the final APK and it's missing. I know I can create a Android App Bundle and then create a APK from .aab with all the modules. but the question is:

is there a way to create full apk (all modules such as: Dynamic features included) directly form source?


Solution

  • I think you can't create full apk directly form source.

    You should take 3 steps:

    1. Build app bundle:

      ./gradlew clean bundleRelease

    2. Generate one apk by bundletool with switch --mode=universal

      java -jar bundletool-all-0.10.2.jar build-apks --bundle=app.aab --output=release.apks --ks=release.keystore --ks-pass=pass:xxxxxx --ks-key-alias=xxxxxxkey --key-pass=pass:xxxxxx --mode=universal

    3. Unzip generated file:

      unzip release.apks