Build android bundle along with apk with one command

Viewed 92

If using Android Gradle Plugin version 3.4.2 or prior the command ./gradlew bundleRelease will generate both bundle and apk of the app. But after upgrading to 3.5 version it generates only the bundle.

Is it possible to get the former behaviour, by means of some configuration or adding some parameters to the command?

It was convenient to have both apk and bundle with one command earlier (the bundle is being uploaded to Google Play, whereas the apk is being uploaded to the Beta by Crashlytics). Now I need to add another step ./gradlew assembleRelease and it takes longer to execute them both.

1 Answers

Finally after some hit and trials, I found that we can run multiple actions in one line command. Like here I am doing a clean first and then creating a bundle and an apk -

gradlew clean bundleFlavorBuildType assembleFlavorBuildType

where Flavor is flavor name and BuildType is release/debug/custom buildType. If you want to build both release and debug apk & aab. e.g. flavor is chocolate

gradlew clean bundleChocolate assembleChocolate

This will output chocolate-relase & chocolate-debug aab, apk both.

Related