How to make use of Android App Bundle in Ionic Applications?
Asked Answered
S

6

22

Hi i am Working with android applications , When i try to upload developer console says the message , "enter image description here"

I hope we can reduce the app size through it , I tried in different ways i cannot get idea for that. Please help me out. Is there any Posibilities to do that.

Sommers answered 7/4, 2019 at 6:21 Comment(3)
please try to generate sign apk using android studioCellobiose
I Don't have any idea to build ionic app in to Android Studio. Can you please refer something.Sommers
if you have android studio then just open android folder from your ionic appCellobiose
A
27

Edit: See Matti's answer below if you're on Cordova >= 8.1.0


You need to have "cordova-android": 8.0.0 or later.

  • run ionic cordova build android --prod --release as usual

  • change into the /platforms/android folder and run ./gradlew bundleRelease. On Windows, the file might be called gradlew.bat instead.

This outputs the bundle at /platforms/android/app/build/outputs/bundle/release/app.aab. Sign this bundle just like you would sign the APK and upload it to the Play Store.

Avignon answered 8/8, 2019 at 14:54 Comment(2)
thanks for the answer let me try , I will get back to you soonSommers
quick note for future Googlers, if you got here from a search for why you're no longer getting apk files from your build: first [email protected] enabled building both apk and aab files by default, and then [email protected] changed to building only aab files by default. github.com/apache/cordova-android/blob/master/RELEASENOTES.mdPastose
S
47

Is supported natively in cordova-android >= 8.1.0

ionic cordova build android --prod --release -- -- --packageType=bundle

Note the extra -- -- dashes before --packageType. First -- is required by cordova. Second one is required because there is another cli tool between (ionic).

If you use cordova without ionic:

cordova build android --prod --release -- --packageType=bundle
Saintmihiel answered 6/1, 2020 at 16:45 Comment(5)
thank you bro. its work. Please version: cordova android >= 8.1.0Djakarta
except when you sign, you cannot sign using apksigner. you need to use jarsigner. e.g. jarsigner -keystore my-release-key.keystore app-release-signed.aab app-release-keyPrima
After I generated this .aab , and trying to upload the play store got "To upload an Android App Bundle you must be enrolled in Play App Signing." this error. Any idea on thisRepulsion
I'm also getting the issue on upload .aab file, To upload an Android App Bundle you must be enrolled in Play App Signing. Is there any more step need to do after created .aab file? Please help any one on this we are urgent on upload in play store.Fibrilla
For sign AAB file this will be 2nd command : jarsigner -sigalg SHA256withRSA -digestalg SHA-256 -keystore releaseApp.jks ./platforms/android/app/build/outputs/bundle/release/app-release.aab releaseGeraldina
A
27

Edit: See Matti's answer below if you're on Cordova >= 8.1.0


You need to have "cordova-android": 8.0.0 or later.

  • run ionic cordova build android --prod --release as usual

  • change into the /platforms/android folder and run ./gradlew bundleRelease. On Windows, the file might be called gradlew.bat instead.

This outputs the bundle at /platforms/android/app/build/outputs/bundle/release/app.aab. Sign this bundle just like you would sign the APK and upload it to the Play Store.

Avignon answered 8/8, 2019 at 14:54 Comment(2)
thanks for the answer let me try , I will get back to you soonSommers
quick note for future Googlers, if you got here from a search for why you're no longer getting apk files from your build: first [email protected] enabled building both apk and aab files by default, and then [email protected] changed to building only aab files by default. github.com/apache/cordova-android/blob/master/RELEASENOTES.mdPastose
G
2

Quick Answer

Step : 1


ionic cordova build android --prod --release -- -- --packageType=bundle

Step : 2


jarsigner -sigalg SHA256withRSA -digestalg SHA-256 -keystore releaseApp.jks ./platforms/android/app/build/outputs/bundle/release/app-release.aab release
Geraldina answered 9/12, 2021 at 16:45 Comment(0)
S
1
ionic cordova build android --prod --release --alias=cos-android --password=abcd  --versionCode=00001 --versionName=00001 -- -- -- --packageType=bundle

cordova build android --prod --release --alias=cos-android --password=abcd  --versionCode=00001 --versionName=00001 -- -- --packageType=bundle`enter code here`
Soapy answered 8/8, 2021 at 7:35 Comment(0)
B
0

Adding to Matti's answer here: I needed to use another extra -- before "--packageType" to make it work. I was using powershell and ionic. The final working command was like this :

ionic cordova build android --prod --release -- -- -- --packageType=bundle

So if the command provided by Matti is generating a release .apk for you instead of an .aab, try this one instead

Bitters answered 25/11, 2021 at 11:29 Comment(0)
T
0

Default release bundle type is .aab (when use --packageType=bundle). Need apk then use below commend :-

 ionic cordova build android --release -- -- --packageType=apk
Thomasinethomason answered 5/12, 2022 at 19:2 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.