I have cloned the AOSP master source code and compiled it. All required .img files are generated in the OUT directory and the size of the overall image is 14.1GB.
Now I am trying to decrease the .img files to as much as possible.
Removed preinstalled apps, but not getting much effect on the sizes.
Can you please suggest/clue me, which is the better way to decrease the image size?
Note: My target device's memory size is too small(Less than 4GB) because of this I am trying to discrete the memory size. I just need to flash android not required all features like AB OTA, BT, camera, etc...
Related
Need to build an android apk less than 20kb, and rest of the contents in the app should download dynamically, does anyone have idea about that.
If i create a simple android app and build it without any source code, it results in 3 MB atleast.
So, so pls someone suggest me how can we create an apk in kb.
I decided this would be a fun challenge, and was able to make a tiny app (no real functionality) that was 16kb. You can find the source code here. It would have been even smaller with only ldpi assets.
Some caveats:
Don't expect an app with any real functionality to come in this small. Keep in mind that 20kb is around 20,000 characters worth of data, which would be about the length of a very short story. 20kb really isn't realistic, and you are going to end up taking up that extra space on your user's phone when you download the "rest of the app" later anyway.
My example has only mdpi assets. Things like launcher icons have to be bundled with your application, so either your icon will look awful on large devices, or you need to modify your requirements.
Some tips:
Enable proguard. Both minification and obfuscation. The latter is a hyper-optimization, but when you are trying to go that small, every bit helps.
Take out any libraries that aren't absolutely mission critical. You aren't going to make it with any of the support library.
Support only the lowest resolution screens you can. ldpi assets will look bad on high density screens, but are exponentially smaller than mdpi, which is exponentially smaller than hdpi, etc. Resources are almost guaranteed to be the largest piece of the app.
Read all of the Shrink Your Code documentation. One great tip if you are using any libraries that provide resources is to use resConfigs to strip out any languages, densities, and native ABIs that you don't need.
Android Studio 3.0 has an "analyze APK" feature that will break down what pieces of the APK are taking up the most space- use that to identify your targets for cutting down the size.
In my app, I am going to have 750 PNG images in my drawable folder. I am getting these images by taking screenshots from my computer.
When I built my app with all of the images, the app's file size was 140MB. Then, When I removed all of the images and rebuilt it, it went down to 2.75 MB.
Is there any way to reduce the amount of memory the PNG images take up? Would reducing the size of my screenshot be an effective solution?
I am going to have 750 PNG images in my drawable folder
Most likely, that is not what you want. res/drawable/ is a synonym for res/drawable-mdpi/. Your image will be resampled to match the density of the device, potentially taking up a lot more heap space. Usually, something like screenshots go in res/drawable-nodpi/, to indicate that the images should not be resampled based on density.
When I built my app with all of the images, the app's memory was 140MB. Then, When I removed all of the images and rebuilt it, it went down to 2.75 MB.
I am going to interpret this as meaning the size of the APK, which in turn controls the starting amount of disk space associated with your app. Please understand that Android does not have an "Application Manager", even though your specific device might have such an app.
Is there any way to reduce the amount of memory the PNG images take up? Would reducing the size of my screenshot be an effective solution?
If by "size" you mean "resolution", then that will reduce the file sizes of the PNG files and should reduce the file size of your APK.
As a now-deleted answer points out, you can also reduce the file size of the PNG files using tools like pngquant, that optimize the PNG in ways that your screenshot tool perhaps did not.
And, you can reduce the size of your APK by reducing the number of screenshots. How many of your users are really going to look at 750 screenshots? You might consider packaging a subset of those with the app, downloading additional ones as needed from some server.
I've used the following as my research :
http://developer.android.com/guide/practices/screens_support.html
Too large APK due to multiple densities and screens sizes?
How to reduce App (.apk) Size
I'm currently working on getting my application to support multiple screen sizes. At the moment I don't have the following in place:
Separate layout files for different screen sizes
Separate images in the relevant image-density folders (ldpi, mdpi, hdpi, xhdpi).
Other info:
All images are .png
I do want to support large screen sizes like tablets
I do not wish to support anything below this size - 320x480
Even though I don't have everything in place yet, my app is highly customized(in terms of graphics) - and is now a little over 4 mb.(.apk size)
If I do add separate layout files, and images - the app .apk file size will probably explode.
Question:
How can I get around this and keep the .apk file size to a minimum?
Idea's I've come up with so far:
Bitmap sampling - and creating an image loader
Downloading images from the net - I wish to avoid doing this unless there's no other option.
Converting some files to .jpeg files - Still a little unclear on how that works.
Using .9.patch image files? I believe this makes layout design easier.. but not sure if I could use that to save on .apk size
You can enable ProGuard in release mode. The ProGuard tool shrinks, optimizes, and obfuscates your code by removing unused code and renaming classes, fields, and methods with semantically obscure names. The result is a smaller sized .apk file that is more difficult to reverse engineer.
http://developer.android.com/tools/help/proguard.html.
Also have a look at the video in the link
http://www.youtube.com/watch?v=amZM8oZBgfk. The talk is about multiversioning.
Tips for reducing .apk file size
http://developer.sonymobile.com/2012/01/31/tips-for-reducing-apk-file-size/
I was doing a little project thing for my school...
I made a simple calculator app...with simple mathematics operations...
And when the apk file is created and installed, it was consuming the memory space of more than 700 kb in the phone.
While in the android market(play store), there are just similar apps which are of low sizes and are taking memory space of less than 500. I was creating app in eclipse...
Will somebody plz help me out with this that how they do make apps of simple lower size.??
The smallest APK I created is ~35kB. Size increases dramatically with the included assets. Check the size of your /res, /assets and, if you have it, /raw folders. The APK size will be larger than those three combined. Further, any included lib counts, and adds bulk, even (and especially) the compatibility library, if you use it.
If you're having lot of graphic assets, then you should probably look at using 9-patches. They save a lot of memory.
Please elaborate your question. When you say memory, are you referring to the RAM OR the actual storage memory ?
If you are referring to storage memory...
The storage memory depends on how big your application is. For e.g. IF you have too many images of large size, then app size will increase.
By the way, 700K is not really too much. You are OK.
guys, I wonder if you put images for each density type (low/medium/high) and there are quite a few of them, won't it increase the size of application footprint on internal memory?
I would hope that android will put only needed resource file from apk to the actual application folder. Can somebody confirm that?
It will increase the size of the .apk, because those images need to be in the .apk. It will not increase the RAM footprint of the app at runtime. When an app is installed it is kept as its original .apk, so the storage space needed will be basically the size of your .apk.