Cordova 8.1+ supports generating Android Bundle (
.aab file). Usually cordova generates an
.apk file for your app. Playstore often warns about
.apk file about it’s bloated size.
To generate an
.aab file, add
--packageType=bundle option to your
cordova build command.
cordova build android --release -- --packageType=bundle
Here is the command I use to generate a singed bundle.
cordova build android --release -- --keystore=~/keystore/dilawar.jks --storePassword=$(KEYSTORE_PASSWORD) --alias=dilawar --password=$(KEYSTORE_PASSWORD) --packageType=bundle --webpack.mode=production
The old way to generate bundle
See the discussion here. And feature request here https://github.com/apache/cordova-android/issues/729 .
These instructions were posted here https://github.com/apache/cordova-android/issues/610#issuecomment-499114935. They worked for me.
- Launch Android Studio
- Go To Import Project (Eclipse ADT, Gradle, etc).
- Select Android platform directory in your project (/platforms/android).
- Wait for finish the Sync
- Go to Build > Generate Sign Bundle
- Complete sign data
- Upload de .aab file generated (in path /platforms/android/outputs/
I did not find any significant reduction in the app size when using the
.aab format (signed bundle). My app was reduced from 6.8MB to 6.5MB :neutral_face: