Reducing android app (apk) size

how to reduce app size in android phone
app size reducer apk
reduce apk size online
android reduce library size
how to compress apk file size
app size reducer app
android size analyzer
apk size reducer online

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...

How you can decrease application size by 60% (In only 5 minutes)?, How do I reduce the size of xamarin Android app? So, let’s see, how we can reduce the size of an android application? Following are the things to be considered to reduce the apk size. Use ProGuard: ProGuard will remove the unused Java code. It helps to significantly reduce the code foot prints.

So, Why do I see that much increase in my app size, Can it be minimized ?

The .apk-file

An .apk-file is not magical at all. It's just a bundle of files which represent the content of an Android application. If you open it in a archive-tool (like 7Zip), you can browser and extract it's contents.

Now this apk file is extracted during installation hence there is increase in the size of the App.

Some more detail regarding compilation

What happens to the .java-files?

Well, first they are normally compiled by an installed JDK implementation. After they are compiled (to .class-files), the dx-tool from the Android SDK then cross-compiles those "normal" java-classes into Dalvik-Bytecode.

This "special" java-code is then interpreted by the DVM (Dalvik Virtual Machine), which is based on the opensource JRE-implementation Apache Harmony.

What happens to the resources i put into the /asset-directory?

Android offers the /assets-directory to add some binary raw-files (e.g. a SQLite Database). Files which are put into this directory are not compiled or optimized.

If you put your files into this directory, this is the kind of behavior you would expect from Android.

What happens to the resources i put into the /res/raw-directory?

Like the /assets-directory, you can also put binary (or other) raw-files in here (e.g. HTML-files for the Help-page). These files are compiled/optimized (if possible).

What happens to the Manifest and the other XML-files?

The Android-Manifest and also the other XML-files (Layouts, Strings, etc.) are stored and "compiled" into a binary XML-format. This is a speed-optimization.

So you got the answer why app size is increased after installation.

Now Is it safer to delete them(Android Libraries), & deleting them can help to decrease apk size?

You can remove google-play-services.jar since it is required only in development environment it's not required in runtime environment.Prompt user to install it from the play store.

Coming to Proguard :: It will remove the unused java classes and will do the code obfuscation.It will not remove unused resources like layout xmls,drawables etc. So my opinion is to run the tool to remove unused resources.

Below are some tips to reduce the size.

You can remove drawable-ldpi folder if you are using it.Since there are no more devices with ldpi screen resolution.

Reduce the use of image drawables(i.e .png or jpg files).Use xml drawables and 9-patch drawables.

Remove any debug info related code.

Avoid code duplication.Follow the principal of Don't Repeat yourself.

I think this is enough to reduce app size in your case.

Here's how to change the icon size on your Android phone, What is the maximum size of APK file in Android? The file size limit is 20MB for free account. Even with large APKs up to 1GB, it will take a few seconds to complete. Reduce the Android app size by compressing image in the app for more download and conversion. Simple, user-friendly way to compress multiple APKs at once. Just drag-and-drop and it’s done.

How To Keep Your Android App Size Down, Android studio provides a handful tool: APK Analyser. APK Analyser will tear down your application and let you know which component in your .apk file is taking  For our example, we will be using the Smart Hotel 360 Mobile Application on GitHub. Feel free to grab a copy of this application to follow along. Let’s take a look now. Looking at our APK from the top-down, we can see that the raw APK size is 34.6 MB and the download size is 23.4 MB.

For those of you doing much smaller projects, consider removing all the app-compat libraries. You may be better off making multiple versions of your app for specific versions of the API. I've seen a 47Kbyte app balloon to 3Mbytes just by adding compatibility libraries.

Summary: to save space, avoid unnecessary libraries, even ones provided by Google (and included in most templates!).

Max size of an Android Application, Code shrinking can help you reduce the size of your APK by deleting unused code and resources. Android Studio 3.3 beta 1 features a preview of the upcoming R8 code shrinking tool, which also performs desugaring and dexing and, according to Google, shrinks code faster than ProGuard. To summarise the page, it mentions below key points that will help reduce the apk size in totality: Use ProGaurd. Remove any debug info you have in the app ( statements such as Log.i ()). Use recommended media formats. Compress images using OptiPNG or PNGCrush. Use 9patch to scale images. Find

Try enabling http://developer.android.com/tools/help/proguard.html , 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.

8 Ways to Reduce Your Android App APK Size, As per the research carried out by Google Play, for every 6 MB increase in APK size, there's a 1% decrease in app installation. So, you can  Reducing APK Size. How fast the application is downloading and how much memory it is using is completely dependent on the size of the APK. And we can reduce the APK size to increase the performance by removing the unnecessary files (by reducing the size of the resources which our app is using). 1. Reducing Resource Size and Their Count

5 Easy Hacks To Reduce The Android APK Size, Let's Sum Up! Remove unused resources, code, and classes. If possible, reuse resources wherever possible. Reduce the size of images using drawable shapes, vector images, 9-patch images or convert to webp format or compress png and jpg images. Reduce the size of native and Java codebase. Use Android app bundle. Reducing app size. When building a release version of your app, consider using the --split-debug-info tag. This tag can dramatically reduce code size. For an example of using this tag, see Obfuscating Dart code. Some of the other things you can do to make your app smaller are: Remove unused resources; Minimize resource imported from libraries

Android Tutorial: How to reduce Android app size?, Apk size reduction technique. So, let's see, how we can reduce the size of an android application? Following are the things to be considered to  Play Store download and enjoy apps, games and digital content for free

How to reduce APK size in android, I solve this issue by adding this code in module app build.gradle file. android { packagingOptions{ exclude 'AndroidManifest.xml' exclude 

Comments
  • Where did you hear the 2MB claim? I would release the app, and always try to reduce the footprint of the app. If a user finds your app helpful, then they won't uninstall it.
  • You are right ,If a user finds app helpful, then they won't uninstall it. 2 MB was my personal opinion because When the user is running low on disk, he sometimes deletes the app that are taking utilises memory, Thanks though
  • If the user runs out of storage on his device, his choice of apps to remove will be the ones he doesn't use or need anymore. My advice would be similar to @ChristopherRucinski above. Make an app that's useful that users will not want to uninstall. Also 2-8 MB for an app storage is a drop in the bucket.
  • I did provide some other ideas that you might find useful in my answer below. Like I said, you might want to upload a few of the pictures so we can see how to decompress them more in ways you might now be aware of. Also, I did say that you can move the data to an SD card! That is probably a good solution to go with until you can find good ways of reducing the APK size
  • You can also try this: https://stackoverflow.com/questions/40154269/reduce-apk-size-android/49472760#49472760
  • Also - Eclipse will often add the android-support library to the project by default. If you aren't using any of these support classes in your code, simply take this jar file out of your project. It will reduce your app's foot print by 600KB.
  • *AndroidUnusedResources.jar available at code.google.com/p/android-unused-resources finds unused resources in android project. * How is it different from proguard?
  • As you said...**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.
  • I have not used AndroidUnusedResources.jar; however, it seems like **AndroidUnusedResources.jar** reduces size of apk, it **shrinks** our code **by removing unused code**. The result is a smaller sized .apk file that does not have unneeded library code.
  • I just added Edit 3. Check it out. This will be a simple test that you can do to see the size of your codebase + libraries vs. the image files.
  • Can you please explain how to remove google-play-services.jar from release (Android Studio)? Can't find that, but play-services client is so big to include it in 0.8MB sized APK... Thanks.
  • add google-play-services as a provided dependencies in your gradle script.
  • How do I do that? I tried renaming apk to zip then decompressing into a folder then compress that folder back to zip and rename zip to apk but it wasn't installable on android device
  • Found this stackoverflow.com/questions/25425172/…