简体   繁体   English

Android Gradle从apk中删除资源

[英]Android Gradle remove resources from apk

I have set a dependency project using gradle, but this project has a lot of resources which are unused in classes which I am using. 我已经使用gradle设置了一个依赖项目,但是这个项目有很多资源在我正在使用的类中没有使用。 Is it possible to somehow filter them? 有可能以某种方式过滤它们吗?

I have been trying to do it using 我一直在尝试使用它

applicationVariants.all { variant ->
    variant.mergeResources.inputResourceSets.each {
        ResourceSet res ->
            res.sourceFiles.each {
                File s ->
                   //here I identify some source files and then I removed them from sourceFiles
            }

    }
}

but that didn't work 但那没用

try proguard which is good at finding/remove unused classes. 尝试proguard ,它擅长查找/删除未使用的类。

proguard integration with gradle on release... 在发布时与gradle集成的proguard ...

build.gradle 'buildTypes'... build.gradle'buildTypes'......

runProguard true
    proguardFile 'yourProguard.txt'

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM