MichaelRocks / paranoid

String obfuscator for Android applications.
Apache License 2.0
673 stars 79 forks source link

Can we do trigger in gradle to turn on and off string obfuscation? #9

Closed prituladima closed 6 years ago

prituladima commented 6 years ago

Can we do trigger in gradle to turn on and off string obfuscation?

MichaelRocks commented 6 years ago

If I understand you correctly you can try and apply the plugin conditionally

if (condition) {
  apply plugin: 'io.michaelrocks.paranoid'
}
prituladima commented 6 years ago

no, in this case we need to remove all @Obfuscate annotations.

prituladima commented 6 years ago

Project can't be compiled without this

MichaelRocks commented 6 years ago

You can add the required runtime dependency to the project manually:

dependencies {
  implementation "io.michaelrocks:paranoid-core:0.1.7"
}
prituladima commented 6 years ago

It worked for my project. Thank you!!! I advice you to add this in description.

MichaelRocks commented 6 years ago

@prituladima Great! OK, I'll do that.

prituladima commented 6 years ago

my properties:

obfuscate.strings.release = true
obfuscate.classes.release = true

my app.gradle:

buildTypes {
        release {
            if (Boolean.parseBoolean(obfuscationProperties['obfuscate.strings.release'])) apply plugin: 'io.michaelrocks.paranoid'
            shrinkResources false
            minifyEnabled  Boolean.parseBoolean(obfuscationProperties['obfuscate.classes.release'])
            proguardFiles fileTree(dir: "proguard", include: ["*.pro"]).asList().toArray()
            proguardFile getDefaultProguardFile('proguard-android.txt')

            signingConfig signingConfigs.release
        }
}