The strategy of slimming APK is to compress the size of APK and reduce the size of APK installation package. Smaller installation packages are more conducive to attracting users to install. Some time ago, an App of our company slimmed down APK, and finally achieved the goal of reducing 10M. Now I need to make a simple summary record and need to slim down an App. First of all, the most important thing is to have a general understanding of the size of the App. The most intuitive way to view the application size is through AndroidStudio's own analyzer.
The first common skill of slimming App is to configure the build.gradle file and open the minifyEnabled to enable the confusing compression mode, which will filter out the jar and class files that are not used in the whole project and confuse the code, thus reducing the size of the dex file. The second is to configure the build.gradle file and open shrinkResources. The function is to deal with the unused image files in the res directory. The specific method is to replace all the unused pictures with small pictures of 1x 1 pixel, thus reducing the size of the res directory. Third, configure the build.gradle file and specify resConfigs, which is used to specify the language pack type compiled during packaging and other unspecified language packs. It will not be packaged as an apk file, thus reducing the size of the apk. Use tripartite tools (such as tinypng) to further compress all png pictures in the project, thus further reducing the size of apk. First, open the tinpng website, drag the png pictures in the project to the webpage, and automatically compress them. Then, download all the compressed pictures and replace the corresponding png pictures in the project. To sum up, this method can greatly reduce the size of the picture, which can be reduced by about 50%, and the effect is very remarkable. It is strongly recommended to master. Fifth, change the pictures of png and jpg into pictures in webp format.