I\'m facing a really weird problem for days now...
I have a Gradle app with two modules, one main module and one library module.
You typically should not enable ProGuard in the library project. ProGuard processes the application and the library together in the application project, which is the most effective approach.
In the library project, you can specify any library-specific ProGuard configuration in build.gradle, e.g.:
defaultConfig {
consumerProguardFiles 'proguard-rules.txt'
}
This file is then packaged in the library aar as proguard.txt
and automatically applied in the application project.
If you do enable ProGuard in a library project (maybe because you want to distribute the library), then you also have to add the proper configuration for processing the library. The Android Gradle build doesn't seem to do this automatically. You can:
android-sdk/tools/proguard/examples/library.pro
to proguard-project.txt
in your library project.-injars
, -outjars
, -libraryjars
, -printmapping
from the file. The Gradle build process automatically provides these options.Enabling/disabling ProGuard independently for the library project and for the application project works fine for me.