I want to remove unused resources from my project to reduce the app size. Is there any way to do it by using Android Studio IDE efficiently?
-
1[look at this](http://cyrilmottier.com/2014/08/26/putting-your-apks-on-diet/) – M D Apr 13 '16 at 07:27
-
Right click on resource and click on Find usage option. it will display if it is used or not. if not then remove it safely. – Wasim K. Memon Apr 13 '16 at 07:31
-
see this :http://stackoverflow.com/questions/6373482/remove-all-unused-resources-from-an-android-project – Suhas Bachewar Apr 13 '16 at 07:34
2 Answers
The Gradle build system for Android supports Resource Shrinking :
the automatic removal of resources that are unused, at build time, in the packaged app. 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.
For example, your application is using Google Play Services to for example access Google Drive functionality, and you are not currently using Google Sign In, then this would remove the various drawable assets for the Sign In buttons.
Note: Resource Shrinking only works in conjunction with code shrinking (such as ProGuard). That's how it can remove unused resources from libraries; normally, all resources in a library are used, and it is only when we remove unused code that it becomes apparent which resources are referenced from the remaining code.
To enable resource shrinking, update your build type as follows:
android {
...
buildTypes {
release {
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
And google recently launched Android Studio 2.0 officially, Now they are giving an option in the IDE itself.
Right click on app --> Refactor --> Remove Unused Resources
It will prompt
Check the box prior confirm action so that you can get rid of unused @id
declarations too.
- In terms of APK optimization consider Selecting a Format fact as well.
- Use WebP Images provide better compression than either JPEG or PNG. Lossy WebP images are supported in Android 4.0 (API level 14) and higher, and lossless and transparent WebP images are supported in Android 4.3 (API level 18) and higher.

- 10,213
- 3
- 52
- 73
-
-
So my application size went from 39.98mb to 39.99mb. But I can't imagine that we don't have any unused resources (especially in all the libraries we are using). – 4ndro1d May 03 '17 at 14:56
-
Be careful, the menu item 'Remove Unused Resources' of Android Studio will remove the resources used by other module too. – EmotionalMan Aug 23 '22 at 08:59
In android studio. You can use Android Lint. It will show " Strings, Resource, import.." not use
Analyze -> Inspect Code -> Whole Project -> OK

- 2,004
- 1
- 10
- 22