Reduce size apk Cordova

I am developing a hybrid application, and now I am in a difficult situation by phone and cordova. Cordoba is now on my PC, and when I do

cordova build android

I get apk that is 3.7 mb. However, if I use the build.phonegap.com route, .apk is only 1.2 mb.

I tried to remove all unnecessary plugins, and even then the build size did not change

How to reduce the size of my cordon apk?

+7
cordova
source share
3 answers

@Frank comment - answer
You can delete all images located in the platform \ android \ res directory if you do not need to display a pop-up image. I reduced the size of my application from 2 MB to 800 KB, more than 50%.

+4
source share

Opening the apk archive, I noticed that not a single js file was modified, and the .map files were large. In my case (I am using TypeScript), the map files are for debugging only, to map the js source code to the ts source code.

I installed cordova-minify

 npm install cordova-minify --save-dev 

I pulled the hook a little to enter the correct folder, disabled the css minifier, which messed up everything and deleted any map file.

My path to the hook:

 hooks/after_prepare/minify.js 

I also used only one splash file (the one for xxxhdpi) was not cropped (neither for the portrait nor for the landscape), following the ionic recommendation

The minimum sizes of the source images should be 2208x2208 px, and his work should be focused on the area, knowing that each generated image will be cropped to the landscape and portrait of the images. Work with spray screens should approximately correspond to the center square (1200x1200 px). ( http://ionicframework.com/docs/v1/cli/icon-splashscreen.html )

only one line in config.xml:

 <splash src="resources/splash.png" density="xxxhdpi"/> 

At the same time, I reduce the size of apk from 4.8M to 2.5M without losing any functions (splash screen).

+1
source share

go to the platform search folder png or jpg delete all the images that you have added and do not want to add. Or delete images you don't need in the assets / imgs / folder

0
source share

All Articles