Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Generating APK with all dynamic features [duplicate]

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?

like image 723
seyed Jafari Avatar asked Jul 06 '19 04:07

seyed Jafari


2 Answers

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

like image 186
AdamN Avatar answered Sep 27 '22 17:09

AdamN


With the command line, you should use :app:bundleRelease which will build an Android App Bundle (.San), then use bundletool to generate the APKs and deploy them to the device.

The full documentation can be found here: https://developer.android.com/studio/command-line/bundletool

like image 25
Pierre Avatar answered Sep 27 '22 17:09

Pierre