How to remove unused resources from libraries?

别等时光非礼了梦想. 提交于 2020-01-01 03:19:13

问题


At first I know Remove all unused resources from an android project, but that is only for projects.

I want to remove unused images from a library like the Google Play Services or the Wearable SDK. I already know that I can remove unwanted languages in gradle by using resConfigs, but I don't know how to remove images and layouts which I don't use. Is there any way to avoid that they are added?


回答1:


I almost missed it to write that there is now a nice solution:

android {
    buildTypes {
        release {
            minifyEnabled true
            shrinkResources true
        }
    }
}

This was annouced on Google+ by Tor Norbye for the build tools version 0.14.0




回答2:


Probbably all you need to know about that is in this very good article from Cyril Mottier : http://cyrilmottier.com/2014/08/26/putting-your-apks-on-diet/

Read the part about Lint ("Use Lint extensively"), as it's the tool that allow you to remove unused resources.

Hope it helps...



来源:https://stackoverflow.com/questions/25843122/how-to-remove-unused-resources-from-libraries

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!