I\'d like to use proguard on my library, but the file (rules) should be set inside the library. That means I don\'t want to set the rules w(hich belong to the library) explicitl
Ok, since proguard might be eating up your classes, try something like this in your app
's proguard-rules.pro file:
keepclass my.library.package.name.** { *;}
that should tell proguard to save all classess from my.library.package.name
so hopefully they won't be missing anymore.
You need to figure out if you want to
That's BEFORE it reaches the application. Your library proguard rules are responsible for making all code accessible and present but you may obfuscate internal classes.
Here's the library build.gradle:
android {
defaultConfig {
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
buildTypes {
release {
minifyEnabled true // Yes, run proguard on the library itself.
}
}
}
If you release this library as open source you don't need this. If you don't release the library to public you don't need this.
I get errors that packages/symbols from the library cannot be found.
Proguard builds a graph of dependencies among classes. At this point the library is a standalone unit so if you didn't supply any rules, none of the classes are ever used so proguard removes them all.
Let the consumer (application) know, which classes of the library are to be kept.
Here's the library build.gradle:
android {
defaultConfig {
// Here's what proguard on the app should do on the library's behalf.
consumerProguardFiles 'proguard-consumer-rules.pro'
}
buildTypes {
release {
minifyEnabled false // No, don't proguard the library itself.
}
}
}
You need to tell proguard what code to keep and what names to keep. Proguard removes all unused code and scrambles names you didn't want to stick around.
You don't tell proguard what to remove, you tell proguard what to keep.