Saeed V.
Saeed V.

Reputation: 99

How to shrink the size of APK file?

i want to shrink the size of my apk file because in my application lots of images there. and because of the image my apk file size is too large..

Upvotes: 2

Views: 3371

Answers (4)

Zar E Ahmer
Zar E Ahmer

Reputation: 34370

Apk is already in compressed form but by following given points you may reduce it to some extent.

  1. Try enabling ProGuard, even without obfuscation and reduce your byte code. It will remove unused Java code from your dependencies
  2. Check for unneeded jars , resources like images or videos.
  3. Convert large images to smaller one by changing resolution . and convert Jpeg images to PNG. But it is even better to put your image on Web and retrieve them using AsyncTask.
  4. Remove unnecessary java.classes and xml from the project.
  5. Don't add large songs or audio to raw or assest.

Upvotes: 0

neteinstein
neteinstein

Reputation: 17613

In images you have no way to reduce the size without reducing the size of the images themselves but you can do one of 2 things:

  1. Not having them on the APK and downloading them on first run (use internal or external storage)
  2. Use shapes to replace images (where they can be replaced)

The code you can reduce by using proguard: Enabling ProGuard in Eclipse for Android

Upvotes: 2

Dmitriy Tarasov
Dmitriy Tarasov

Reputation: 1969

If you have many images you can exclude them from the *.apk, download them at first run and save on sdcard

Upvotes: 0

Thorsten Dittmar
Thorsten Dittmar

Reputation: 56727

An APK file is basically a ZIP file. There's no way of reducing its size any further. Instead, you should check whether you can

  1. reduce image sizes (either the dimensions or better compression) or
  2. replace some of the images by custom drawing code, creating them at runtime

If neither 1. or 2. are possible, I guess you just have to accept the APK size as it is.

Upvotes: 2

Related Questions