Wednesday, March 9, 2016

How to remove some density drawable from android library

Leave a Comment

My app import admob:

com.google.android.gms:play-services-ads:8.4.0

But it make my app very big, I found there are "drawable-xxxhdpi", "drawable-tvdpi" from this library with very large images, I want to delete(exclude) those from this library.

I used "resConfigs" in gradle to just include the density folders I needed before,

but not sure since when the "resConfigs" for density is not supported,

https://code.google.com/p/android/issues/detail?id=179136

The apk split in density seems not fit my requirements.

what should I do now?

2 Answers

Answers 1

You can try splitting and exluding the xxxhdpi and tvdpi from the releases apks.

  splits {          density {                   enable true                    exclude "xxxhdpi", "tvdpi",         }    } 

This will generate differents apks in order to submit later to the playstore. For more information about splits here.

Answers 2

You can try to use Resource Shrinking which will remove unwanted resources from libraries. From its docs:

In addition to removing resources in your project that are not actually needed at runtime, this also removes resources from libraries you are depending on if they are not actually needed by your application

However, you'll need to configure Proguard as well, which is a different problem on its own. But if you are already have it configured, just add shrinkResources true to your gradle script as in the example below.

buildTypes {     release {         minifyEnabled true         shrinkResources true         proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'     } } 
If You Enjoyed This, Take 5 Seconds To Share It

0 comments:

Post a Comment