Reputation: 2211
I am currently trying to remove unused graphical resources from an app in compile time. I know Android Studio can help me manually remove unused ones, but I need to be able to remove them in compile time; this way, I can run Proguard to remove unused classes, and then remove any images referenced from those classes.
Right now I can do this, which gets me any unused image shrunk to a 1x1 black dot:
android {
buildTypes {
release {
minifyEnabled true
shrinkResources true
}
}
}
I can't have those files there (even shrunk). Is there a way to make Proguard actually remove those images (instead of shrink them) or rename them? Maybe I could use some other tool?
edit: just for clarification, I would need the resources rendered "unused" by Proguard to be removed or renamed.
Upvotes: 2
Views: 1551
Reputation: 45648
ProGuard (or the new Jack compiler) only shrink and obfuscate bytecode. The resource shrinking tool subsequently removes or replaces unused resource files.
ProGuard's commercial extension DexGuard shrinks, optimizes, and obfuscates bytecode, the Android manifest, resources, resource files, asset files, and native libraries. As far as I'm aware, it's the only tool that analyzes and optimizes all contents at the same time. For instance, it indeed removes unused classes and corresponding unused resources and resource files.
[we develop ProGuard and DexGuard at GuardSquare]
Upvotes: 1
Reputation: 452
If you are looking for some utility, you can use https://code.google.com/archive/p/android-unused-resources/
or https://github.com/KeepSafe/android-resource-remover
Hope this helps.
Upvotes: 0
Reputation: 994
To remove unused resources you can use Android Lint tool from ADT 16. It will help you not only to remove unused resources, but also to find potential bugs.
http://tools.android.com/tips/lint
You can also enable proguard in release mode
The ProGuard tool shrinks, optimizes, and obfuscates your code by removing unused code and renaming classes, fields, and methods with semantically obscure names. The result is a smaller sized .apk file that is more difficult to reverse engineer.
http://developer.android.com/tools/help/proguard.html
You can easily search for unused resources from Android Studio. Just press Control + Alt + Shift + i and type "Unused resources" (without quotes). That will execute lint. Super easy way how run lint commands (and other stuff from IDE).
Upvotes: 0