简体   繁体   中英

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. 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 integration with gradle on release...

build.gradle 'buildTypes'...

runProguard true
    proguardFile 'yourProguard.txt'

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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