My project has dynamic feature module and I would like to generate debug or release APK including the dynamic feature. Currently I can get only base APK file.
Basically I would generate an APK file like normal application. But I couldn't do with dynamic feature. Yes, I know dynamic feature will work based on AAB.
Is there any ways to make a normal(base + all modules) APK file?. Please help on this.
Thanks
I don't see it documented anywhere, but the Android Gradle build tools include tasks to extract the universal APK for you. You can use something similar to:
./gradlew :yourmodule:packageDebugUniversalApk
Under the hood it uses bundletool and does essentially the same thing as the other answer, but it's nice to be able to do it from Gradle.
You can specify if your on demand module needs to be included in the universal APK that is usually generated for older devices, and then you can use bundletool to generate an Universal APK from the App Bundle:.
In this particular case, you can use something like:
bundletool build-apks --bundle <bundle_file> --output <APKS file> --ks <key_store> --key-pass <jks password> --ks-key-alias <key_alias> --ks-pass <key password> --overwrite --mode=universal
The key point is to include the --mode=universal this instruct bundletool to generate an Universal APK that will include all modules that have <dist:fusing dist:include="true"/> in the manifest.
In a similar way, when you run your project from Android Studio on a device, using the default configuration for Run (Deploy = Default APK) it includes all of your on demand modules.
Instead, when you run the application from Studio using the Run configuration (Deploy = APK from AppBundle) you can pick and choose which modules are installed.
However, in both cases, you cannot test on demand module downloads if you don't go through the Play store.
Note (November 2020)
As reported in another answer below, the Android Gradle Plugin includes a couple of undocumented tasks that can be used to generate Debug and unsigned Release universal APKs of your application.
The task related to the Debug version can be a quick alternative if you just need this type of build:
./gradlew :app:packageDebugUniversalApk
This task will generate (by default) app/build/outputs/universal_apk/debug/app-debug-universal.apk.
Update June 2019
Google introduced at I/O Internal App Sharing that allows to allow testing 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.
Download bundletool jar file from Github (Latest release > Assets > bundletool-all-version.jar file). Rename that file to bundletool.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 generated
below is the command to generate the universal apk
java -jar bundletool.jar build-apks --bundle=nhl.aab --output=nhl.apks
--mode=universal
`
Related
I'm developing an android application with react-native (0.59), and I want to test it on different devices. My goal is to create an .apk file that can be installed by simply transferring the file, without any requirement for development server running, usb cables, etc..
I have looked at different reply on previous questions about the subject but so far nothing as worked.
This reply still needs a dev-server to run: How to generate dev APK file without asking for dev settings server ip in react native
This reply generate an apk that won't install on the device with the error "app not installed": Build and Install unsigned apk on device without the development server?
I have tried the publish method from the react-native docs (ref: https://facebook.github.io/react-native/docs/signed-apk-android), I generated the .aab file, then I use bundletools to convert it with apks, as explained here: Generate Apk file from aab file (android app bundle) in this answer:
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.
But unfortunately in my case, when I open the .zip file, there's no file called universal.apk:
All the .apk are pretty small in size (around 10mb, while the .aab file is 300).
Is there any other solution?
After you go through https://facebook.github.io/react-native/docs/signed-apk-android you can simply run
// for build and run
react-native run-android --variant=release
and take apk in
<rn_project_dir>/android/app/build/outputs/apk/release/app-release.apk
I want to configure my personal app to be built as an android app bundle rather than apk in Jenkins. How do I configure my Jenkins to build aab and not apk
You need BundleTool You can use bundletool to create an aab and sign it and even test it.
You can install Bundletool just like another CLI utility and execute commands in Jenkins.
Or you can just execute a Gradle task like bundleRelease to generate your release aab.
Here is much detailed on how to do so.
https://developer.android.com/studio/build/building-cmdline#bundletool-build
https://developer.android.com/studio/command-line/bundletool
I'm looking for a solution to generate an APK from Android App Bundle which will help me to share the App for internal testing rather publishing on Google Play Beta Testing.
Is there a way or a command 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.
pfmaggi mentioned Internal App Sharing, which is indeed the best way to test exactly what users will get.
An alternative, which isn't as accurate and doesn't always work in some edge cases, is building a universal APK by passing the flag --mode=universal to the build-apks command in bundletool. It still generates an .apks file, but you can then extract the single .apk file from it (using unzip or bundletool's extract-apks command).
You may try this command instead of generating new APK file.
This uses bundletool to install APKS file which generated from bundletool build-apks
bundletool install-apks --apks=file-name.apks
Whenever I use command line to produce feature APKs, it produces 2 APK. My feature apk and base apk. However, I don't upload them to Play Store. It says : Sorry we could not save your changes" Whenever I use Android Studio -> Build -> Generate Signed APK it only produces my base feature apk and when I try to upload the zip folder to Play Store, it says "Your Feature APKs contains "productdetail" apk either does not exist or was not included". Any idea why can it happen? Or any help how to produce v1+v2 signed APKs to upload them to Play Store?
At the moment, there are some bugs building your Instant App via the Studio menus (Build -> Generate Signed APK). You should run gradle directly, either by using the far right gradle panel in Studio and executing the top level assembleRelease task or via command line (./gradlew assembleRelease).
If you haven't already, to setup gradle to sign your APKs (v1+v2) use signingConfigs as per here.
Each of your feature modules (including base) will need to have signingConfigs setup in their build.gradle file to ensure each feature APK is signed correctly.
I want to submite an application to Google Market. I found there is only one apk file generated in a project, its path is Project1Project/Project1/build/apk/Project1-debug-unaligned.apk
It looks like it's a debug version. Where do I find (if any) a release version of an application or how do I generate it?
Since Android Studio is based on IntelliJ, that's how to do it in IntelliJ:
Build -> Generate Signed APK
and provide it with your key and its password.
You can build an unsigned release version. See the answer here. I don't see an easy way to do it from the GUI, but you can use the shell command:
./gradlew assembleRelease
Make sure to cd to your project's directory before running the command. This will produce the file
Project1Project/Project1/build/apk/Project1-release-unaligned.apk
If you run ./gradlew assemble, both the release and debug version will be built.
More documentation here.
From Android Studio 1.3.1, the ready-to-publish apk location is :
app -> app-release.apk
This should be published to Google Play
Intermediate apks are at :
app -> build -> outputs -> apk -> app-release-unaligned.apk
This is Intermediate result of Signing process, should not be published to Google Play
Android gradle produces apk in two binaries: Unaligned and Aligned. Unaligned refers to how the data, files are structured within the APK file. A utility called zipalign modifies the APK to align data in a way that is optimized for users. Unaligned simply skips the zipalign stage.
Whereas an Aligned APK is an optimized version. The files are more structured and compressed, which helps the app run faster. They are also optimized for RAM usage so they can consume less RAM on the devices.
you will also see size difference in the APK generated.