Generate Apk file from aab file (android app bundle)
By default, the IDE does not use app bundles to deploy your app to a
local device for testing
Refer bundletool command
For Debug apk command,
bundletool build-apks --bundle=/MyApp/my_app.aab --output=/MyApp/my_app.apks
For Release apk command,
bundletool build-apks --bundle=/MyApp/my_app.aab --output=/MyApp/my_app.apks
--ks=/MyApp/keystore.jks
--ks-pass=file:/MyApp/keystore.pwd
--ks-key-alias=MyKeyAlias
--key-pass=file:/MyApp/key.pwd
Edit:
I have been using following commands while testing my release build for aab(I hope it helps others too):
Download
bundletool
jar file from Github Repository (Latest release > Assets > bundletool-all-version.jar file). Rename that file tobundletool.jar
Generate your aab file from Android Studio eg: myapp-release.aab
Run following command:
java -jar "path/to/bundletool.jar" build-apks --bundle=myapp-release.aab --output=myapp.apks --ks="/path/to/myapp-release.keystore" --ks-pass=pass:myapp-keystore-pass --ks-key-alias=myapp-alias --key-pass=pass:myapp-alias-pass
myapp.apks
file will be generatedMake sure your device is connected to your machine
Now run following command to install it on your device:
java -jar "path/to/bundletool.jar" install-apks --apks=myapp.apks
Edit 2:
If you need to extract a single .apk
file from the .aab
file, you can add a extra param --mode=universal
to the bundletool
command:
bundletool build-apks --bundle=/MyApp/my_app.aab --output=/MyApp/my_app.apks \
--mode=universal \
--ks=/MyApp/keystore.jks \
--ks-pass=file:/MyApp/keystore.pwd \
--ks-key-alias=MyKeyAlias \
--key-pass=file:/MyApp/key.pwd
and execute
unzip -p /MyApp/my_app.apks universal.apk > /MyApp/my_app.apk
this will generate a single a /MyApp/my_app.apk
file that can be shared an installed by any device app installer
Uploading AAB Bundle to AppCenter downloads an APK File?
The Android OS can only install APKs. If you upload Android App Bundles to the Google Play Store, the Play Store then generates optimized APKs for your end users.
Microsoft's App Center on the other hand generates an unoptimized universal APK.
"When you distribute Android Application Bundle (AAB), App Center generates a universal APK, signs it with a generated signing key, and distributes it to a device."
Source: https://learn.microsoft.com/en-us/appcenter/distribution/uploading
How to generate an APK (NOT APKS ) from AAB using bundletool?
I think that the best option is to use Internal App Sharing that allows to test 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.
If you want to go the bundletool route, you need to generate an universal apk. Take a look at this answer on how to do it.
Generating a standalone apk from a bundle file (app.aab)
The standalone APKs are only generated if minSdkVersion < 21
.
If you want a universal APK, you can use --mode=universal
which will build a single APK that contains everything. As documented below https://developer.android.com/studio/command-line/bundletool
Related Topics
Scale Image to Fill Imageview Width and Keep Aspect Ratio
Android Animation Is Not Finished in Onanimationend
Android How to Display 2 Listviews in One Activity One After the Other
Trigger Mediascanner on Specific Path (Folder), How To
Vectordrawable - Is It Available Somehow for Pre-Lollipop Versions of Android
How to Use Both Ontouch and Onclick for an Imagebutton
Creating a Searchview That Looks Like the Material Design Guidelines
How to Generate Class Diagram (Uml) on Android Studio (Intellij Idea)
How Does the Mapping Between Android Resources and Resources Id Work
How to Downgrade My Sdk Version
Android Boot_Completed Not Received When Application Is Closed
Could Not Find Com.Android.Tools.Build:Aapt2:3.2.0
How to Create a Help Overlay Like You See in a Few Android Apps and Ics
Textwatcher for More Than One Edittext
How to Receive a Notification When the User Powers Off the Device
Version Conflict Updating to Play-Services 9.4.0 Android Studio 2.2