Enabling ProGuard for a single module in a 2 module project

100 Views Asked by At

Assuming I have an Android library project (named X) which I use to create an AAR file for later use, can I have this structure below?

    Project X
        Module A
            proguard disabled
            consumes classes from module B
        Module B
            proguard enabled
            consumes native Java/Android SDK classes

When I build Project X, I want to create an AAR file which will publicly expose classes from Module A.

Note: Enabling ProGuard in Module A too and excluding everything with a proguard rule is not an option in my case.

1

There are 1 best solutions below

0
shizhen On BEST ANSWER

As of current Android Studio 3.4, it does not support your project structure if the said Project X and Module A as well as Module B are all Android Library projects. Instead of your project structure, you can try below structure:

Module A
    proguard disabled
    dependsOn B
    consumes classes from module B
Module B
    proguard enabled
    consumes native Java/Android SDK classes
Project X
    proguard disabled
    dependsOn A and B