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
Related
It's been so long since I develop a mobile app in react native, when I'm developing before, I usually generate a release apk and send it to my clients so that they can test it and have experienced it, but now when I build a release in react native, it returns a .aab instead of .apk, how can I send my application to the clients when I only get .aab format on my project?
It using for different android devices installation by google play store. that's why you can use apk build for manual installation.
You must use the below command for the testing build.
$ cd android
$ ./gradlew assembleRelease
As mentioned repeatedly in many places .aab file is efficient. But we need .apk for regular task (except PlayStore).
So:-
Create signed output of Android project Link
Use command $ npx react-native run-android for debugging.
Finally $ npx react-native run-android --variant=release Link, to create release version, which is created at android/app/build/outputs/bundle/release/app.apk
Go crazy
Just for the information. If you upload the AAB to Google Play instead of the APK, it will lead to smaller download sizes. AAB lets Google Play create different APKs to different devices, based on the device screen density, language, and CPU architecture. So, if you're able to create AAB's, use them over APK's.
cd android
./gradlew bundleRelease
The generated AAB can be found under
android/app/build/outputs/bundle/release/app-release.aab
, and is ready to be uploaded to Google Play
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.
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.
I have generate apk from jenkins job and publishing it to google playstore. Now i need to generate android app bundle from jenkins job. Please guide to generate aab from jenkins job. Thanks!
You can configure your jenkins job to invoke a gradle build script.
Use the gradle task (to build the release variant)
./gradlew bundleRelease
More info in the official doc.
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
`
I am developing an android application. All the things is going well when I run the application into genymotion virtual device.And Since the apk is stored in F:...\app\build\outputs\apk location. So I just want to collect it from this location and download it to install in a android phone.As I simultaneously updating the application with code but this apk doesn't provide me the updated apk file according to the updated code .They just give me the old apk file even if i run my application again and again from the android studio. Can anyone suggest me why this is happening ??? I just want to run this apk into phone or download this apk file for another purpose.
This three steps will do Go build->Build apk
Go to Build > Build APK to generate a normal APK.
Go to Build > Generate Signed APK to generate signed APK.
Signed APK are those which we generate to release our application. Here it is, why is it necessary to generate signed APKs: Why should I Sign my Application APK before release
If you build a debug APK, it will still work on all devices but you cannot release it.
From terminal run the following command to make sure that you get the updated apk.
1. gradle clean (from windows )
-or-
./gradlew clean (from linux) -
Above command deletes the build folder.
2. gradle build (from windows)
-or-
./gradlew build(from linux)
Above command builds all the flavor for your application.
Edit: Original answer
Signed apk is needed to install in any other non debug device. This will be same as the debug app that runs in your test device/emulator.
Build -> Generate signed apk