Search code examples
androidkotlinproguardminifyandroid-r8

As a library developer: how to avoid the user's Proguard


I'm a library developer.

I'm experiencing issues with the users of my library regarding Proguard. Seems like their Proguard is messing the models of the library.

I have defined in the proguard-rules.pro file of the library, which are the packages and classes I don't want to shrink, as the following:

-keep class com.x.library.data.models.** {*;}

Seems like their Proguard shrinks everything anyways.

Is there a way to avoid their Proguard to shrink the library I develop? Thanks in advance.


Solution

  • You can use consumerProguardFiles in your library defaultConfig to specify a Proguard rules file that will get merged with the one in the app.

    See also the following questions: