androidcordovagradleproguardcordova-plugin-proguard

Proguard with Cordova Android 4?


I had ProGuard running for release builds when Cordova built with Ant, but now that Gradle is used my project's release builds aren't being obfuscated (my "cordova build --release android" output shows a step for :CordovaLib:mergeReleaseProguardFiles, but no other proguard/minification/obfuscation entries).

With Ant, my project.properties file referred to my proguard-project.txt file using the proguard.config parameter.

How do I configure this to work now that Cordova uses Gradle?


Solution

  • Have a look at the updated Proguard Documentation, you now have to change the build.gradle file.

    Change the buildType release section to something like this

    android {
    ...
    
      buildTypes {
        release {
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'),
            'proguard-rules.pro'
        }
      }
    }