Thursday, August 11, 2016

How to Reduce Your Android App Size and Boost Your Downloads?


App size really matters when you are deploying your application at Google Play Store.
Here, we have shared some effective approaches that our android developers usually use to reduce the app size.

Vector Drawables


Android is supporting the vector drawable for an older version of android devices with the release of 23.2 Support Library. With Android Studio, users provide a way to convert SVG to Vector Drawables.

Here, Android developers shouldn’t have to worry about the different device DPI’s. And, this approach will minimize the app’s size significantly.

Avoid Duplication


You have to make sure that your app doesn’t have duplicate functionality or assets. It is recommended to avoid having unnecessary files in your APK.

Moreover, you have to understand which Android APIs you should use and the full functionality that each offers.

It could be that one Android API is better than another for your application.

You can also avoid duplicated assets like strings, bitmaps and so on. as they waste a lot of space.

Additionally, the duplicate code will also needlessly increase the size of the delivered binary.

Google Play Services


Choose the compiling APIs broadly.

In the previous versions of Google Play Services before 6.5, you have to compile the entire package of APIs into your app.

It becomes more problematic to keep the number of methods in your app such as library methods, framework APIs, and your own code under the 65,536 limit.

However, from version 6.5, you can instead selectively compile Google Play service APIs into your application.

For example, you can replace the following line in your build.gradle file to include only the Google Fit and Android Wear APIs.

compile 'com.google.android.gms:play-services:8.4.0'

with these lines:

compile 'com.google.android.gms:play-services-gcm:8.4.0'
compile 'com.google.android.gms:play-services-wearable:8.4.0'

Removable Debug Information


It is recommended to remove all debug-related functionality from the application.

Generally, the application doesn’t see or use this data, and the Android operating system doesn’t need to run the application.

Thus, the debug information wastes spaces, recommended to remove.

Reuse resources whenever possible


One of the important optimizations you should learn when starting android app development is to reuse stuff.

Reusing helps you to keep a smooth scrolling performance in a ListView or a RecyclerView.
However, reusing can help to minimize the final size of the APK.

For example:


Android offers many utilities to re-color an asset by using the new android:tint and android:tintMode on Android L.

You can also avoid packaging resources that are only a rotated equivalent of another resource. For example – We have 2 images, named ic_arrow_expand and ic_arrow_collapse.

You can easily get rid of ic_arrow_collapse to develop a RotateDrawable that relies on ic_arrow_expand. Using this technique, you can minimize the time required by your designer to maintain and export the collapsed asset variant.

Removal Debug Symbol from native libraries


If your application is still in development phase, it makes sense to use debug symbols and still needs debugging.

Are debug symbols still appearing when you compile a release build? Yes.

If you want to remove it, it is recommended to remove the Debug symbols from native libraries (.so files).

This can be done by using the arm-eabi-strip command from the Android NDK.

Use Proguard


Android app developers are using Proguard for code obfuscation. It removes unused Java code from the dependencies.

If you are using Proguard, it smaller apk file size, which is tough to inverse engineer. To enable proguard:

build.gradle

android {
 ...
 buildTypes {
     release {
         minifyEnabled true
         proguardFiles getDefaultProguardFile('proguard-android.txt'), 
                'proguard-rules.pro'
     }
 }

These are some tips to adopt for minimizing your android app size and ultimately, it increases downloads. If you have more tips that can be implemented when Android app development process, let us know through the comment.

No comments:

Post a Comment