In addition to eliminating unused resources, you can specify the list of localizations you need , as well as other alternative resources in the gradle config parameter in the shrinkResources true config, which will significantly reduce the size of the resulting file:
android { defaultConfig { ... //для версий gradle <= 2.10 resConfigs "en", "fr", "ru" resConfigs "nodpi", "xhdpi", "xxhdpi", "xxxhdpi" // для версий gradle > 2.10 resConfigs = ["en", "fr", "ru"] resConfigs = ["nodpi", "xhdpi", "xxhdpi", "xxxhdpi"] } ... buildTypes { release { shrinkResources true minifyEnabled true proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } }
Here - leave only English, French and Russian locale and support for screens with XHDPI to XXXHDPI (new versions of gradle changed the format of the line, both formats are indicated in the config, but you need to choose only one depending on the version of gradle used in the project).
It’s no secret that by default the Android application contains localizations in over one hundred languages and alternative resources on all possible devices, including TVs. If you can control your resources, the libraries used in the project drag with them all possible localizations and sizes, this will help get rid of them. Similarly, you can exclude other alternative resources, such as support for tablets, if your application does not support them.
For excluded resources, when you start your application, the default resources will be used, but you can generally exclude them by specifying the necessary restrictions in the manifest.
Also now there is a tool in gradle - Multiply APK and a very powerful tool for configuring project content - the splits section , which allows you to manipulate not only resources, locales, but also supported architectures. I did not use it myself, so I will leave only a link to the offdoc and a brief example:
android { defaultConfig { ... } ... splits { density { // Кофигурация разрешений экрана enable true // Будут исключены из сборки exclude "ldpi", "xxhdpi", "xxxhdpi" // Оставить поддержку только следующих экранов compatibleScreens 'small', 'normal', 'large', 'xlarge' } language { enable true // включены в сборку языки include ""en", "fr", "ru" } // Конфигурация архитектур abi { enable true reset() // Включенные в сборку архитектуры include "x86", "armeabi-v7a", "mips" // не делать универсальную сборку universalApk false } } }
There are commands that indicate which resources will be included in the project (include), which are excluded (exclude) and so on. many different features worth exploring.