Home » Android » android – Is proguard.cfg needed for library projects?

android – Is proguard.cfg needed for library projects?

Posted by: admin April 23, 2020 Leave a comment


Assuming I need to apply the same rules for both an application project and a library project on which it relies, do I need to duplicate the content of proguard.cfg from the application to the library project?

In other words, does the application’s proguard.cfg “take over” all the library projects on which it depends, or must I explicitly specify rules for each of the library projects?

How to&Answers:

Library projects by themselves don’t run ProGuard, so they don’t use any configuration.

Application projects obfuscate the entire code base, including any referenced libraries, so they need proper configuration for the application code and for the library code.


It appears that the answer is “No”: Proguard will obfuscate code from the libraries too.

But that was in 2010 and we know very well that specifications keep changing, especially in the Android development tools. So if a more authoritative answer comes along, I will accept it.


  1. In build.gradle of library project, add line: consumerProguardFiles 'proguard-rules.pro' in buildTypes as:

    buildTypes {
    release {
        minifyEnabled true
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        consumerProguardFiles 'proguard-rules.pro'


  2. In build.gradle of root project, enable minifyEnabled.
    The libraray proguard will work.