I have created an apk whose size is 80mb. I have set minifyEnabled true
shrinkResources true
in Gradle file. Now I want to optimize the images so that it will reduce the APK size. How can I optimize the images in android?
Asked
Active
Viewed 3,511 times
1

Prashant Sable
- 1,003
- 7
- 19

Antim Arora
- 15
- 1
- 6
-
When you distribute to the play store, Use android app bundles (AAB) instead of APK's, AAB's create lots of small APKs for specific configurations of android e.g an APK for xxhdpi devices where only the xxhdpi resources are in the APK, this method can shrink APK size on the device by up to 60% i think i read somewhere. – MichaelStoddart Nov 01 '19 at 07:57
-
Decrease quality of images, for example by convert them to jpeg format (quality down to 50%) or decrease image resolution, or download part of images in app – Style-7 Nov 01 '19 at 12:46
1 Answers
1
When you set the minifyEnabled property to true, it only make your app code become jumble and yes it will reduce your APK or bundle but not your images . Code shrinking (also known as tree shaking), is the process of removing code that R8 determines is not required at runtime. This process can greatly reduce your app's size if, for example, your app includes many library dependencies but utilizes only a small part of their functionality. Please refer to this.
If you want to reduze all your image stored in drawable, considered this:
- You can use scalable Drawable objects in place of image files
- You can also reduce your APK size by procedurally rendering your images. Procedural rendering frees up space because you no longer store an image file in your APK
- You can reduce PNG file sizes without losing image quality using tools like pngcrush, pngquant, or zopflipng
- Use WebP file format and Use vector graphics
Detail explanation you can find here.

moxspoy
- 154
- 1
- 4