Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remove unused localizations from APK

For an Android app with no localizations (default language only), how can you exclude localizations from Gradle dependencies?

Background: The app is a line-of-business app for which the only language that needs support is US English. The app includes com.google.android.gms:play-services-gcm:7.0.0 for push notification support. The GCM library includes localizations in 73 languages. I'd rather they not be included. That keeps the APK smaller. Additionally, if a user is running with a non-English language, I don't want the experience to be a mix of English and localized text.

like image 308
Edward Brey Avatar asked Mar 28 '15 15:03

Edward Brey


People also ask

Why reduce APK size?

No user would like to install a very large APK and consume his data on downloading that APK. The APK size will make an impact on your app performance about How fast it loads, How much memory it consumes, and How much memory it uses. It is very important to take a look at your APK size while developing.

What is minify Android?

minify is an Android tool that will decrease the size of your application when you go to build it. It's extremely useful as it means smaller apk files! It detects any code or libraries that aren't being used and ignores them from your final apk.

What is R8 Android?

What is R8? R8 is an app shrinking tool that is used to reduce the size of your application. This tool present in Android Studio works with the rules of Proguard. R8 will convert your app's code into optimized Dalvik code.

How to shrink code in Android Studio?

Shrink your code. Code shrinking with R8 is enabled by default when you set the minifyEnabled property to true . Code shrinking (also known as tree shaking), is the process of removing code that R8 determines is not required at runtime.


1 Answers

In build.gradle, add resConfigs to limit the languages:

android {
    defaultConfig {
        // other configuration here
        resConfigs "en"
    }
}
like image 113
CommonsWare Avatar answered Oct 01 '22 02:10

CommonsWare