简体   繁体   中英

Reduce apk size

I am developing an android application in which there are hundreds of high quality images(512x512px to 1000x1000 px and above) and hence the apk size has become too (more than 400mb) large. So, is there a way to compress my .png images or any other way to reduce the app size. I also read about proguard but will it delete my images? Thanks in advance!

您可以尝试使用像pngcrush这样的东西来减少文件大小,或者您可以尝试将它们远程存储在服务器上并根据需要将它们下载到设备并缓存它们(很可能您不需要所有图像同时)

An APK with 400 MB is really huge, so you need to compress images, use these links to compress http://www.tinypng.com http://www.compresspng.com http://www.punypng.com You could also choose to load the images from server and store it in sdcard on application launch. So your application doesn't need to store images inside itself. I recommend you to store & load images from server.

How to reduce apk size -

  1. Image Compression

    • Pre-process images-Manually optimize images in res folder using external tools, and set cruncherEnabled to false to keep optimization.
    • Pre-process .PNG using zopflipng.
    • In android version above 4.0 WEBP images can be used.
    • For icons vector drawables is better option.
  2. Code Compression

    -Use proguard to compress the bytecode in raw apk file.ClassyShark is apk explorer tool allow to look into dex files

    • Remove resources using resConfigs.
    • Set shrinkResource true in build.gradle file to remove unnecessary resources left by proguard.
    • ArscBlamer is tool to compress strings.(For apps which have multiple string folder for multiple android versions)

for more info about apk size visit this link

As stated in earlier answers there are ways to compress images, but these will not take you too far. You need to change you app to dynamically download images. To save space on the user's device, you should probably let users pick which images or groups of images they want to download, instead of downloading all images.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM