buzoherbert buzoherbert - 1 year ago 86
Android Question

Gradle - Are proguard configurations inherited?

This might be too broad, but I would like an explanation on how Proguard and minification configurations are passed between projects and their dependencies to understand how deeply are these operations made in my project's dependency tree.

I have on

of `themodule':

buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
dependencies {
compile project(':someothermodule')
compile 'some.maven.central.library'

By the configuration it seems clear that the classes inside
will be minifyed and obfuscated, but what happens with the classes of
? Will they also be minifyed and obfuscated? Even if
minifyEnabled true

What happens if 'someothermodule' is just a .jar dependency?

What happens with the configurations of

Are the Proguard configurations of the module being built cascading down to its dependencies or each of them follows its own rules?

Answer Source

Technically, it is the following :

Library projects by themselves don't run ProGuard, so they don't use any configuration.

Application projects obfuscate the entire code base, including any referenced libraries, so they need proper configuration for the application code and for the library code.

I had a small case where I had a Facebook library as a gradle dependency and since we were obfuscating the code with minifyEnabled:true we had to keep all its code from being obfuscated, using the regular keep commmands such as :

-keep class com.facebook.** { *; }

Additionally, and regarding the .jar obfuscation, you can check this other post


Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download