I hope someone can answer what I consider the main Gradle / Proguard question.
I have a very simple Android project. This project contains a main application module called app and a library module for Android support libraries called AndroidSupport .
I want to run Proguard exclusively on AndroidSupport (i.e. NOT in the general application), because I have problems with testing the hardware in the application when it is Proguard-ed. I hope that I can minimize AndroidSupport myself, so that I donβt need Proguard my application code (and thus avoid problems running the tests).
Here is my app build.gradle . Please note that Proguard is disabled:
apply plugin: 'com.android.application' android { compileSdkVersion 22 buildToolsVersion "22.0.1" defaultConfig { applicationId "com.example.androidsupportlibproject" minSdkVersion 9 targetSdkVersion 22 versionCode 1 versionName "1.0" } buildTypes { debug { minifyEnabled false //Proguard DISABLED proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } } dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) compile project(':AndroidSupport') }
My AndroidSupport module has Proguard ENABLED:
apply plugin: 'com.android.library' android { compileSdkVersion 22 buildToolsVersion "22.0.1" defaultConfig { minSdkVersion 9 targetSdkVersion 22 } buildTypes { release { minifyEnabled true //Proguard ENABLED proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } } dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) compile 'com.android.support:support-v4:22.2.0' compile 'com.android.support:appcompat-v7:22.2.0' compile 'com.android.support:recyclerview-v7:22.2.0' compile 'com.android.support:support-annotations:22.2.0' }
My AndroidSupport module proguard-rules.pro looks like this:
-dontobfuscate -keep class android.support.v4.** { *; } -keep interface android.support.v4.app.** { *; }
If the app has Proguard enabled and AndroidSupport disabled by Proguard, I can use consumerProguardFiles proguard-rules.pro to minimize AndroidSupport .
But when I use the above configuration, I get the following error:
Error:Execution failed for task ':AndroidSupport:proguardRelease'. java.io.IOException: The output jar is empty. Did you specify the proper '-keep' options?`
Does anyone know if this is possible? Enable Proguard ONLY on the dependent library module, but not on the application itself?
Thanks in advance!