Removing unused resources (Android Performance Patterns Season 4 ep8)

Android Developers · 33K views · 2015 · 2:56

Open on YouTube

Software performance & optimizationSoftware practice, open source & careerstutorialdated

Why Stack Overflow recommends it

Stack Overflow users link it when answering how to shrink an APK or remove unused resources from third-party libraries, since it is the official walkthrough of minifyEnabled and shrinkResources.

Recommended by 2 people across 2 different months, 2015 to 2021.

What it is

A short episode of the Android Performance Patterns series in which Colt McAnlis explains why APKs stay bloated even when you remove your own unused resources, since included libraries ship assets your app never uses. It shows how Gradle's minifyEnabled and shrinkResources settings strip them out. Presented by the Android Developers channel.

What people said

Recommends Colt McAnlis · 2015-10 · Stack Overflow · on “How do I remove unused resources from third-party libraries I’ve included on Android?”

This answer is summarized from Removing Unused Resources [this video] which explains how to use minifyEnabled and shrinkResources, which are covered in more depth at the Official document page [LINK] . It’s a common problem for third-party libraries to include assets that your application codepath does not use, and it’s critically important to remove those assets in order to produce smaller APK files for your users. Thankfully, the latest version of Gradle and Android Studio provides a solution to help. By setting minifyEnabled and shrinkResources to true in your Gradle configuration, the system will go forth removing unused resources from your application. android { ... buildTypes { release { mi

Recommends Farbod Salamat-Zadeh · 2015-12 · Stack Overflow · on “Reducing android app (apk) size”

Generally, in ProGuard, you can use the following to shrink your APK (this is in your module's build.gradle file): ... android { ... buildTypes { release { minifyEnabled true shrinkResources true proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } ... } ... Specifically, look at minifyEnabled true and shrinkResources true : minifyEnabled is responsible for obfuscating and shrinking your code files (e.g. Java). It is the main feature of ProGuard, and helps to shrink your APK as well as making it difficult to reverse engineer. shrinkResources is used to remove unused resource files (such as images and other assets). For example, if you are compiling with an A

Cites Ole Pannier · 2021-04 · Stack Overflow · on “How can I get rid of unnecessary code in .apk file?”

More than that isn't possible. Here is the official video from Android Developers, what is clearly showing what will be removed maximum. So Android keeps the data (that looks unnecessary to you, for the case it need some attributes in the future.). [this video]