12

I have developed a simple Android application. Its APK size is 8MB. Can anyone tell me how to reduce the APK size?

Bart
  • 19,692
  • 7
  • 68
  • 77
Arunima
  • 141
  • 1
  • 2
  • 9

3 Answers3

10
  • Try enabling ProGuard, even without obfuscation. It will remove unused Java code from your dependencies.
  • See if you have unneeded dependencies - JARs that you've added but aren't using
  • Check your resources for large images or other files. You may want to change their format or resolution, or remove them if they're not in use.
  • Optimize your final APK (after ProGuard) with Facebook's ReDex. This should reduce the code size as well as potentially improve performance.
orip
  • 73,323
  • 21
  • 116
  • 148
8

1) First you need to enable Proguard even without obfuscation. It will remove unused Java code from your dependencies.

2) Second, use 9-patch images instead of very high resolution images.

3) Remove some unnecessary code and also JAR files that haven't be used.

4) Ensure you are using .png images instead of .jpg.

5) Use different images for different screen resolutions.

6) Check your layout folder for unnecessary XML files

Dan Dascalescu
  • 143,271
  • 52
  • 317
  • 404
Piyush
  • 18,895
  • 5
  • 32
  • 63
  • May I ask why should we use PNG instead JPG? I thought it was the other way around due to file size? – platypus Jan 01 '17 at 09:13
3

You can use Lint to check for things like unused resources or unnecessary views in your layout files. Additionally, you can use Proguard to obfuscate your code, which in doing so will reduce class and variable name lengths.

Phil
  • 35,852
  • 23
  • 123
  • 164