Search code examples
androidcordovaapkproguardcordova-plugin-proguard

How to use proguard in cordova android App


I have a finished cordova project and i want to use proguard inorder to prevent others from reverse engineering the APK.But i have trouble doing this.

In http://developer.android.com/tools/help/proguard.html

It says that "When you create an Android project, a proguard.cfg file is automatically generated in the root directory of the project. " But i cannot find a such file. So how do i apply proguard to my app?

Thank you


Solution

  • You need to uncomment below lines from your project.properties file

    To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):

    proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
    

    Also, if you are using Webview with JS, uncomment following lines in proguard-project.txt and specify the fully qualified class name to the JavaScript interface class:

    -keepclassmembers class com.your.package.YourJSInterfaceClass {
       public *;
    }