I would be now publishing my first app on Google play store. I have already compressed images used in my app. And I have some questions regarding the app size.
If the size of app is less that 2 MB then there are less chances that user will uninstall the app, is my this statement true for apps belonging to education field ?
However, When I see my apk file in windows it shows 3.10 MB but when it gets installed in device as viewed from App info it shows:
Total............................8.68 MB
App..............................7.02 MB
USB storage app..................0.00 B
Data.............................1.66 MB (perhaps it is the size of sqlite db + ttf's)
SD card..........................0.00B
So, Why do I see that much increase in my app size, Can it be minimized ?
And, I am using 4 libraries (jars) in my project which are in Android Private Libraries
, but these library have their copy outside this folder also.
Is it safer to delete them, & deleting them can help to decrease apk size?
Also I have visited many web pages describing what Proguard
does, I truly understand how Proguard reduces size of apk, it shrinks, optimizes, and obfuscates our 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. But I do not know How should be my proguard-project.txt
should look like ?
I am using 4 libraries in my app namely easyfacebookandroidsdk_2.3.jar
,android-support-v7-appcompat.jar
,google-play-services.jar
& android-support-v4.jar
.
Currently my proguard-properties.txt
looks like this & also it do not uses WebView
# To enable ProGuard in your project, edit project.properties
# to define the proguard.config property as described in that file.
#
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in ${sdk.dir}/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the ProGuard
# include property in project.properties.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# Add any project specific keep options here:
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
-keep class com.facebook.** { *; }
-keepattributes Signature
So, what lines should I add in my proguard-properties.txt
so that it can remove unused references,classes,etc., in order to reduce the apk size ?
Using AndroidUnusedResources.jar available at https://code.google.com/p/android-unused-resources/ finds unused resources in android project.
I think this is the same thing which proguard has already done ? Or should it also be used after enabling proguard ?
Also you can mention in your answer anything that is missing which you feel should be shared.
Thanks in Advance...
Almost solely because of your res folder images! You should have around 4 copies of each image in the drawable-mdpi, -hdpi, xhdpi folders. The only difference is that theu are all different sizes.
Chances are there aren't multiple copies of those jar files! Just one copy with links to it!
Yes, what you said was right about Proguard. However, realize that you are talking about text files here. They are really small. I mean really small in size (kilobyte-wise). Your problem is something in the megabyte (MB) size. That is images!!!!
Repeat. That is images!!!!
Enabling proguard will save a little bit size-wise.
Yes, these are all more important in your case. Please read and apply these. Good luck!
If a user finds your app helpful, then they won't uninstall it; however, there are several things you can do
async
them into your app? Allow users to move data to an SD card.
[EDIT] After the app has been in the Play Store for a while, check the Developer Console and see which screen size/density is used the least. Remove that drawable folder from your app! This could reduce the size a good amount! But, check my edit below for the cons of this approach!!
You might want to show a few of the images, as that would allow us to see what you are dealing with
@Ashwin N Bhanushali Has a great answer here for the part of the question I did not answer, but he basically told you that there was nothing you could really do except what I said, plus an idea or 2 more.
I did have another idea that was based on one of his ideas that would be even better, because Android Studio does not include the drawable-ldpi folder in the project anymore. So it would only be helpful if you use Eclipse, mine expands
This works because pictures take up way more bytes than text files. And all those drawables have the same images in them (just different sizes). Removing the images from less used buckets can save a lot of space!!
Take note that removing those buckets from your app will mean that your app will have to do more work on those phones that use the removed buckets. The app might be slower for those users; however, the app size can be reduced more.
Text files take up almost nothing. Take a look in the file system for your project!
In the picture below. Check the size of...
In your case, you will see that the java folder is probably really small in size (10 through a few hundred KBs); however, you will see that the res folder is really large in size (several MBs!).
That means that any compression, or reduction in your code base will be very small and not worth it!!
Therefore the best way to reduce your APK size is to follow my instructions above!
Here is a test that you can do right away and see the absolute maximum (plus more) that tools like Proguard, and AndroidUnusedResources.jar will reduce the size of the APK file!
What you have to do is remove ALL code from your project except for the class declarations. Do the same for Abstract classes, Interfaces, Enums, etc... Your project structure should stay the same, and you should not be using any external libraries at all then.
So you will have something like this for all of your classes...
public class CustomClass {
private String variable; // List of variables
public CustomClass() { ... } // List of constructors
public getVariable() { ... } // List of Assessors
public setVariable(String val) { ... } // List of Mutators
private String helperMethods() { ... } // List of helper and other methods
}
You should remove all the code inside of the classes, interfaces, enums, etc to look like the following; however, leave all your images alone!! ...
public CustomClass {
// Everything is removed!! No libraries used, nothing. Unless certain classes
// require some methods like Activity. Those methods should be empty though!
}
Now compile and build your project.
Check the new APK size to your current APK.
Install the app on your phone, and check the new app size to your current app size
If you notice that the 2 apps are still around the same size, then spending all your time with Proguard and AndroidUnusedResources.jar is meaningless at this stage. This is a test to see where you would spend your personal resources in app size reduction.