I work on a publicly released android library. And, for external release, I need to run proguard with the following options:
-keep public class com.example.package_one.* {
public protected *;
}
-keep public class com.example.package_one.subpackage_one.* {
public protected *;
}
-keep public class com.example.package_one.subpackage_two.* {
public protected *;
}
-keep public class com.example.package_one.subpackage_three.* {
public protected *;
}
-keep public class com.example.package_one.subpackage_four.* {
public protected *;
}
-keep public class com.example.package_one.subpackage_four.sub_subpackage_one.* {
public protected *;
}
-keepclassmembers class * implements android.os.Parcelable {
static ** CREATOR;
}
But, the release version of the library is also used internally unproguarded, so I need three types of builds: debug, release, and proguarded release.
To this end I currently have the below build.gradle file for my library:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.3.1'
}
}
apply plugin: 'com.android.library'
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
minSdkVersion 17
targetSdkVersion 23
}
sourceSets {
main {}
debug.setRoot('build-types/debug')
release.setRoot('build-types/release')
}
buildTypes {
debug {}
release {}
proguarded{
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'),
'proguard-rules.pro'
}
}
}
dependencies {
}
But, when I try to create the proguarded build, all the packages I say to keep are kept, yet all my classes that extend Parcelable, other than those in the packages I say to keep, are obfuscated.
I tried putting a bug in the proguard-android.txt file on my computer, and the build did not crash, so I know that file isn't actually being read. But I don't know what to do to make all my classes that extend Parcelable not be obfuscated, other than explicitly telling proguard to not obfuscate each and every one.
This same proguard file used to work with my old Ant builds, so my guess is I am somehow messing up my gradle build script. Can anyone tell how?