How to obfuscate the code in ionic platform

hi
i tried uncomment the following line in platforms\android\project.properties

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

and new a file proguard-project.txt in the same folder, then:
ionic build android --release

but looks do not work.
any idea?

1 Like

In my case, I have placed proguard-android.txt file inside platforms\android. Add your rules for obfuscation as per requirement. Add below lines in your build.gradle file:

android {

    defaultPublishConfig "release"

    buildTypes {
        release {
            //signingConfig signingConfigs.release
            minifyEnabled true
            debuggable false
            shrinkResources true
            proguardFile 'proguard-android.txt'
        }
    }
}

This works fine and obfuscates my src files. However, the drawback is that I am unable to avoid obfuscation of files present in the assets directory due to which my application crashes.

Also, the solution you mentioned about uncommenting the lines is applicable for eclipse projects (Not sure).

Thanks.