google / material-design-icons

Material Design icons by Google (Material Symbols)
http://google.github.io/material-design-icons/
Apache License 2.0
50.47k stars 9.56k forks source link

Create an aar artifact for Android #77

Open vijaysharm opened 9 years ago

vijaysharm commented 9 years ago

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.

geovanisouza92 commented 9 years ago

+1

buchandersenn commented 9 years ago

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.

sevar83 commented 9 years ago

+1

schildbach commented 9 years ago

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.

sevar83 commented 9 years ago

ProGuard uses some heuristics to analyze if any drawable is accessed programatically, but who could trust it? I personally wouldn't!

buchandersenn commented 9 years ago

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=

jestelle commented 9 years ago

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,

timrae commented 8 years ago

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?

virsir commented 8 years ago

+1