0

I have one Android project contains 2 modules:

  • app - which is a standard Android application.
  • core - which is Java-library module.

I've done it this way because I need to use the core functionality in the non-Android environment, as a standalone jar.

Now, I need to create another application that needs to use the core functionality + Java packages inside the app module (I can't get them out of there).

So I thought using build variants can help me. I created 2 build variants, one for the old application and second to the new application.

Everything works fine, but I can see that all my resources in the main directory are being packaged into the apk of the new application, even though the second application requires a small number of resources.

I've searched about how to exclude unused resources like this, but in my case, I need to remove only unused resources, not entire folders.

Shalu T D
  • 3,921
  • 2
  • 26
  • 37
user1080528
  • 75
  • 1
  • 6

1 Answers1

0

I think you should use the shrink resources functionality which removes unused resources during compilation. You don't need to manually point to directories or files to exclude them - gradle will do that for you :)

https://developer.android.com/studio/build/shrink-code.html#shrink-resources

and in the code:

buildTypes {
            newApp {
                minifyEnabled true 
                shrinkResources true
            }
}
Mariusz Brona
  • 1,549
  • 10
  • 12