I'm just created a new Android Library project using Gradle and would like the code to be optimized and obfuscated with via Proguard.
Here is the android portion the build.gradle file:
android {
compileSdkVersion 19
buildToolsVersion "19.0.1"
defaultConfig {
minSdkVersion 14
targetSdkVersion 19
versionCode 1
versionName "1.0"
}
release {
runProguard true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.txt'
}
}
When I run the gradle build command from terminal it fails at :library:proguardRelease with the message:
* What went wrong:
Execution failed for task ':library:proguardRelease'.
> java.io.IOException: The output jar is empty. Did you specify the proper '-keep' options?
Does anybody know why this is?
Gradle 1.10 JVM 1.6.0_65 Progruard 4.10
The following
build.gradle
file works for me with Proguard when executinggradlew assembleRelease
.Note it is set up to read the release keystore info from a config file (and I've included the debug key cert in the project, since its needed for Maps API v2 in debug mode), and passwords from the command line:
Here are the instructions to set up the config files to read keystore info:
Here's the path to the file/project on Github if you want to clone and test it yourself: https://github.com/barbeau/gpstest/blob/master/GPSTest/build.gradle
proguard.cfg
is also in the GPSTest subdirectory (same directory asbuild.gradle
): https://github.com/barbeau/gpstest/blob/master/GPSTest/proguard.cfg