I have developed the app using ionic 3 and now while generating android apk file it \'s size getting way too big.
before the API integration The File Size Wa
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
Looks like a bug (not sure) but when live reload is active, the tree shaking feature causes the build to emit several chunk files into the www
folder and i think the more you reload, the more files you'd have in there.
So you'd see files in the form
0.7f0f403f3c9f5914fbce.js
0.7f0f403f3c9f5914fbce.js.map
1.0db885b5a44ebd4ca57e.js
1.0db885b5a44ebd4ca57e.js.map
...and the number goes 0, 1, 2, ... n
You simply need to delete the www
folder to discard the stale chunk files and rebuild your app.
The apk size should be justifiable after that.
You should use --prod
flag while building apk for production. It minimizes the size by compressing the files.
ionic build android --prod --release
check sourceMap
in angular.json
if true
put it in false
Please use below command:
ionic cordova build android --minifycss --optimizejs --minifyjs --release
[note:- "ionic cordova build android --prod --release" command have email pattern matching issue in a form, always give invalid email error hence not used that command]
Use below link for more details:
https://ionicframework.com/docs/cli/cordova/build/
Run cordova clean
to cleanup project from build artifacts.