tags:

views:

174

answers:

4

Help!

When I install my app on the phone to test, it is showing up to be a HUGE size, 11.35 MB. It is a very simple app that lets user browse through fun-facts. The only reason I can think of is that there are 14 JPEG files in the drawables which serve as background images of the fun-facts. The average size of these is about 500 KB.

I'd like to trim the size of my app, so as not to use up the precious resources on the user's device. Other than just getting rid of the pictures, are there ways to optimize the size of apk file?

EDIT: The pictures are photos taken by me using the Android phone itself.

+5  A: 

I would recommend that you compress the .jpg files as much as possible, this should greatly reduce the size of your .apk file. A tool such as Paint.NET which is free should help you do this. It has great resizing options.

Nate Bross
I would say *reduce* the JPEG size (i.e. JPEG quality) rather than *compress* them. JPEGs aren't very squishy.
Christopher
Good point, but depending on the level of compression in the images, there could be room for additional compression in addition to reducing the size.
Nate Bross
Nate Bross, Christopher, thanks. I installed Paint.NET. (great tool!) Both reducing the quality while saving OR Resizing option, reduce the size while not significantly altering the picture. I'm not sure about the *compress* option, how to do that (I'm assuming you don't mean compress to a .7z or something). But this will work for me.
OceanBlue
Most people see a "quality" setting in JPEG images, some correctly call this compression. It has to do with how much information you are willing to loose. When you reduce the "quality" you are simply letting the JPEG algorithm decide what pixels it can guess the color of. More guesses, smaller size.
Tom Slick
@Tom Slick. OK, that makes sense. Good info. Thanks!
OceanBlue
+6  A: 

Make sure that your jpg's aren't stored in any higher resolution than necessary. A nice Android phone has a screen resolution of around 800 x 480, so your backgrounds shouldn't contain any more pixels than that (unless your app supports some kind of zooming). Also, are the backgrounds photographs? If not, you may find that using a vector based image format like svg, or one with a dynamic palette like gif, will reduce the file size even more.

Dana the Sane
OceanBlue
Gif is a bitmap format . Did you mean SVG?
Chris Huang-Leaver
Yes, you're right. I've updated the question to be more accurate.
Dana the Sane
+1  A: 

Other answers mention shrinking images. You might also consider trying ProGuard to shrink your bytecode. Here's an article on applying ProGuard to an Android app.

Mauricio Scheffer
any explanations for the downvote?
Mauricio Scheffer
Shrinking the bytecode would have a barely noticable effect on APK size, especially in comparison to cutting down the size of the 10MB+ of JPEGs.
Christopher
@Christopher: other answers have already mentioned shrinking images, but nobody has mentioned shrinking code, so I'm giving the OP another tool to consider.
Mauricio Scheffer
I see, but I guess nobody mentioned optimising using ProGuard because it would have virtually no benefit for an app like this.
Christopher
OceanBlue
+1  A: 

There are two things I can point out from experience.

  1. If you use eclipse to create apk file then the resources are duplicated (atleast it happened in my case), you can try using ant and build.xml to create the apk and compare the size.
  2. Also look into aliasing the resources. The link for it is here.
omermuhammed
Can you elaborate on resources being "duplicated"?
Christopher
In my case I had unzipped my apk and found the contents of res folder (drawable, layout folders etc) in top level directory, AND the res folder containing all the assets, thus they were being packaged in twice. I thought that this must be something unique to my Eclipse workspace. And when I started doing commandline builds with Ant, it all worked out and the res folder was packaged in once. Thats the reason I asked you to look into it.
omermuhammed