IONIC Android Apk File size Way Too Big ! how to decrease the size of app for android?

后端 未结 7 1941
一向
一向 2021-01-04 21:11

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

相关标签:
7条回答
  • 2021-01-04 21:46

    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

    0 讨论(0)
  • 2021-01-04 21:47

    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.

    0 讨论(0)
  • 2021-01-04 21:56

    You should use --prod flag while building apk for production. It minimizes the size by compressing the files.

    ionic build android --prod --release
    
    0 讨论(0)
  • 2021-01-04 22:05

    check sourceMap in angular.json if true put it in false

    0 讨论(0)
  • 2021-01-04 22:07

    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/

    0 讨论(0)
  • 2021-01-04 22:09

    Run cordova clean to cleanup project from build artifacts.

    0 讨论(0)
提交回复
热议问题