BJMg
BJMg

Reputation: 61

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

Upvotes: 3

Views: 383

Answers (1)

Robert Rowntree
Robert Rowntree

Reputation: 6289

try proguard which is good at finding/remove unused classes.

proguard integration with gradle on release...

build.gradle 'buildTypes'...

runProguard true
    proguardFile 'yourProguard.txt'

Upvotes: 1

Related Questions