I created the app using Ionic and the Android APK file size is too big.
Before the API integration The File Size was 4.8MB. When I integrated the API I modified just 10 Pages now the APK file size is 71 MB.
Here are the Cordova Plugins I have used:
cordova-plugin-console
cordova-plugin-datepicker
cordova-plugin-device
cordova-plugin-network-information
cordova-plugin-splashscreen
cordova-plugin-statusbar
cordova-plugin-whitelist
cordova-plugin-x-socialsharing
cordova-sqlite-storage
es6-promise-plugin
ionic-plugin-keyboard
I unzipped the APK file to find out what going on. I looked at the build
Folder in assets/www/
folder which alone was 357MB and it contains JavaScript and MAP files and a 4.5MB CSS file.
How do I decrease the size of the Ionic Android APK file?
Some of the ways to reduce the apk size: Take prod build - It would minify and uglify the code. Use the following comment. ionic cordova build android —prod.
You can compress an APK file (rar, zip), but it has to be decompressed in order to work. ProGuard is a free Java class file shrinker, optimizer, obfuscator, and preverifier. It detects and removes unused classes, fields, methods, and attributes. It optimizes bytecode and removes unused instructions.
Each expansion file can be up to 2GB in size. Users must run Play Store version 5.2 or higher to install 100MB APKs.
You should use the --prod
and --release
flags when building the APK file for production. It reduces the size by compressing the files.
ionic build android --prod --release
For people running into that issue with newer versions of Ionic:
In Ionic 4.3 there seems to be a bug in the build scripts. If you run a debug build, and then a release/production build, the www
folder is not cleared and you will have all the sourcemap (.js.map) files in the www folder and thus in the final apk file.
See https://github.com/ionic-team/ionic-cli/issues/3954
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With