How to Disable Proguard for Building My Android App

How do I disable proguard for building my Android app?

Try to delete the proguard directory in your project. So proguard will forget its mapping.

How to enable proguard for only one module

The solution is to look up for the methods and classess that needs to be exempted and add them to the proguard rules as follows..

-keep class com.mm.** {*;}
-keep class com.company.** {*;}
-keepclassmembers class com.mm.** {*;}
-keepclassmembers class com.company.** {*;}

How to disable Proguard settings for an external dependency jar?

  1. It's not possible at the moment to exclude a dependency when running ProGuard.

  2. You should only proguard the library if you want to obfuscate parts of it. This is only really useful if you want to only offer part of it as a public API. You definitively do not want to remove dead code, since you don't know what will get used or not.

  3. On the app side, you probably don't need to put anything special, unless the library code requires you to not obfuscate some specific class. If that's the case you should actually publish this from the library so that the app uses that automatically. There's a sample called libProguardConsumerFiles that shows how to do this using the consumerProguardFiles properties. This will include a proguard rule file in the library packaging that will get used by whomever consumes the library.

Enable/disable ProGuard in the product flavor

For your scenario, it feels like you are trying to model different phases of your development lifecycle. That's really where build types are for. While Gradle (and hence Gradle for Android) ships with debug and release build types, you can define your own:

buildTypes {
debug {
applicationIdSuffix ".d"
versionNameSuffix "-debug"
}

release {
signingConfig signingConfigs.release
}

mezzanine.initWith(buildTypes.release)

mezzanine {
applicationIdSuffix ".mezz"
debuggable true
}
}

Here, I:

  • Configure the debug and release build types

  • Clone a mezzanine build type from release

  • Override some settings on mezzanine, replacing what they had been defined as originally on release



Related Topics



Leave a reply



Submit