Skip to content Skip to sidebar Skip to footer

How To Exclude Specific Resource Folder From Apk

I need to remove several resource folders from apk. Now I have the following folders: res/drawable res/drawable-land res/drawable-land-xxhdpi In the process of gradle assembly, I

Solution 1:

You can use flavors

In the module's build.gradle :

buildTypes {
    ...
}

# this is mandatory since Android Studio 3
flavorDimensions "a_flavor_dimension"

productFlavors {
    minimal_resources {
        # optionnal if there is only one dimension
        dimension "a_flavor_dimension"
    }
    additional_resources {
        dimension "a_flavor_dimension"
    }
}

Each time you create a resource, or a resource directory (right click on res / New / Android resource directory), choose the additional_resources flavor in the Source set selector.

The files are located in src/additional_resources/res/... instead of of src/main/res/...

When generating the apk you will be able to choose which flavor(s) you want to build.


Post a Comment for "How To Exclude Specific Resource Folder From Apk"