Open vijaysharm opened 9 years ago
+1
I actually tried this myself, using this repository as a base and adding my own gradle build files. But even though I stripped unused resources from my project (and saved some 50+ MB), the process wasn't entirely efficient. Adding the aar still increased my final APK size by some 2-3 MB, even without referencing any of the icons.
Perhaps I just configured proguard incorrectly or something. I would love to see it working if the overhead could be reduced to < 1 MB.
+1
Is proguard able to prune resources at all? Note you can create resource references programmatically, e.g. res.getIdentifier(prefix + "_logo", "drawable", packageName)
, and I never had those resources stripped away by proguard.
ProGuard uses some heuristics to analyze if any drawable is accessed programatically, but who could trust it? I personally wouldn't!
Yes, Gradle + ProGuard can prune ressources. See http://tools.android.com/tech-docs/new-build-system/resource-shrinking
There are ways to specifically tell the tool chain to keep ressources, if you don't trust the heuristics mentioned by sevar83. In my experiments the material design icons wasn't pruned enough, probably because the heuristics "played it safe."
I've given up experimenting with this for now, and use an Android Studio plugin to add material design icons to my project instead: https://plugins.jetbrains.com/plugin/7658?pr=
Thanks Vijay. We'll have a look into this when we're able to, but there may be downsides to this approach.
We're also working with the Android Studio team on ways to make it easier to use this icon set in your projects, so stay tuned,
With added support for vector drawables in the new support library, it might make sense to have an aar with just the drawable-anydpi-v21 folders. The size should then be pretty manageable. Any plans for this?
+1
The Android build system prunes unused resources, which would mean, if we could wrap these icons into an aar, the unused ones would be striped from the final apk. This would certainly make adding this icons much easier to any Android project.