Antim Arora
Antim Arora

Reputation: 15

Image optimization Android to reduce the APK size

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?

Upvotes: 1

Views: 3630

Answers (1)

moxspoy
moxspoy

Reputation: 830

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:

  1. You can use scalable Drawable objects in place of image files
  2. 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
  3. You can reduce PNG file sizes without losing image quality using tools like pngcrush, pngquant, or zopflipng
  4. Use WebP file format and Use vector graphics

Detail explanation you can find here.

Upvotes: 1

Related Questions