问题
Is there any way to generate an apk file from android app Bundle via terminal or using android studio?
回答1:
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
回答2:
Ok here is the complete way I had to do
1. Download bundletool-all-0.10.3.jar from this link , download latest version available
2. Create an app bundle using android studio and locate its path
in my case its E:\Projects\Android\Temp\app\build\outputs\bundle\debug\app.aab
3. Copy the bundletools jar to some location and get its path
in my case its E:\Temp\bundletool-all-0.6.0.jar
use this command
java -jar "BUNDLE_TOOL_JAR_PATH" build-apks --bundle="BUNDLE_PATH" --output=YOUR_OUTPUT_NAME.apks
In my case it will be
java -jar "E:\Temp\bundletool-all-0.6.0.jar" build-apks --bundle="E:\Projects\Android\Temp\app\build\outputs\bundle\debug\app.aab" --output=out_bundle_archive_set.apks
4. This will create a file out_bundle_archive_set.apks
, rename it to .zip out_bundle_archive_set.zip
, extract this file and done You will have multiple apks
Check this blog post for more info . also check out official site
回答3:
People have already explained on how to do this with the command-line. For completion, I thought I'd also show the way to do it via the UI in Android Studio.
When you open your "Run/Debug Configurations", you can select "APK from app bundle" (instead of "Default APK").
See screenshot:
回答4:
So far nobody has provided the solution to get the APK from an AAB.
This solution will generate a universal binary as an apk.
Add --mode=universal to your bundletool command (if you need a signed app, use the --ks parameters as required).
bundletool build-apks --bundle=/MyApp/my_app.aab --output=/MyApp/my_app.apks
--mode=universal
Change the output file name from .apks to .zip
Unzip and explore
The file universal.apk is your app
This universal binary will likely be quite big but is a great solution for sending to the QA department or distributing the App anywhere other than the Google Play store.
回答5:
There's a tool called bundletool
, which can create APK's out of your AAB file:
Find details about this tool here: https://developer.android.com/studio/command-line/bundletool
But here some highlights taken from that site:
Building APKs
When bundletool generates APKs from your app bundle, it includes them in a container called an APK set archive, which uses the .apks file extension. To generate an APK set for all device configurations your app supports from your app bundle, use the bundletool build-apks command, as shown below:
bundletool build-apks --bundle=/MyApp/my_app.aab --output=/MyApp/my_app.apks
Note that the command above creates an APK set of unsigned APKs. If you want to deploy the APKs to a device, you need to also include your app’s signing information, as shown in the command below.
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
Installing APKs
bundletool install-apks --apks=/MyApp/my_app.apks
Generate a device-specific set of APKs
bundletool build-apks --connected-device --bundle=/MyApp/my_app.aab --output=/MyApp/my_app.apks
回答6:
Refer Geek Dashboard for more info.
For those who are looking to generate a single universal APK file from your Android App Bundle, you must use --universal
flag while running the build-apks
command.
java -jar bundletool.jar build-apks --bundle=your_app.aab --output=your_app.apks --mode=universal
Where bundletool.jar is the bundletool jar file you downloaded here
your_app.aab is the Android App Bundle of your App
your_app.apks is the output APKs Archive File that will be generated once you run the command.
While running the above command make sure you place bundletool.jar and your AAB file in the same folder.
Now, you need to change the your_app.apks file format to your_app.zip and extract it to find the universal.apk file
Note: Use –overwrite
flag to overwrite the APKs file if there is already one with the same name. Otherwise, bundletool
command will throw you a fatal error.
回答7:
According to the docs, you can use ./gradlew :base:bundleDebug
to build where base is your module name. You can try that command in the terminal inside Android Studio.
回答8:
on mac it can be easily done using homebrew
brew install bundletool
you can use the command below to generate apks
bundletool build-apks --bundle=aab_path.aab --output=release.apks
above command generates apks file which can later be extracted to give various apk files. To see all generated files change the extension from .apks to .zip and just extract the files.
then you can install apk using this command on connected device
bundletool install-apks --apks=release.apks
来源:https://stackoverflow.com/questions/53040047/generate-apk-file-from-aab-file-android-app-bundle