Skip to content

Configuration

Efra Espada edited this page Aug 6, 2019 · 9 revisions

By default, the plugin will encrypt every strings.xml file inside src/main folder but you can choose a different configuration.

Let's suppose we have this application project (app and library).

With this schema and no configuration defined, only two files will be encrypted at compilation time.

StringCare allows adding more resource folders and string file names to find strings to hide.

Additional Resource Folders

On root-level build.gradle file:

apply plugin: StringCare
stringcare {
    modules {
        app {
            stringFiles = ["strings.xml","more_strings.xml"]
            srcFolders = ["src/main", "src/other_variant_source"]
        }
        library {
            srcFolders = ['src/other_folder/main']
        }
    }
}

Module build.gradle files:

// app build.gradle
android {
    sourceSets {
        main.res.srcDirs = ['src/main/res', 'src/other_variant_source/res']
    }
}
// library build.gradle
android {
    sourceSets {
        main.res.srcDirs = ['src/other_folder/res']
    }
}

Main Module

On root-level build.gradle file:

The default value is app

apply plugin: StringCare
stringcare {
    main_module "base"
}

Debug Logs

On root-level build.gradle file:

apply plugin: StringCare
stringcare {
    debug true
}

Dynamic Application Ids

By default, it uses the default applicationId defined in the main module; any other applicationId configuration must be defined in SC.

BuildVariant Usage

android {
    defaultConfig {
        applicationId "com.watermelon.app"
    }
    flavorDimensions "type"
    buildTypes {
        release {
            applicationIdSuffix ".release"
        }
        debug {
            applicationIdSuffix ".debug"
        }
    }
    productFlavors {
        prod {
            dimension "type"
        }
        dev {
            dimension "type"
            applicationIdSuffix ".dev"
        }
    }
}
apply plugin: StringCare
stringcare {
    variants {
        prodDebug {
            applicationId = "com.watermelon.app.debug"
        }
        prodRelease {
            applicationId = "com.watermelon.app.release"
        }
        devDebug {
            applicationId = "com.watermelon.app.dev.debug"
        }
        devRelease {
            applicationId = "com.watermelon.app.dev.release"
        }
    }
}

Flavor Usage

android {
    defaultConfig {
        applicationId "com.watermelon.app"
    }
    flavorDimensions "type"
    productFlavors {
        prod {
            dimension "type"
        }
        dev {
            dimension "type"
            applicationIdSuffix ".dev"
        }
    }
}
apply plugin: StringCare
stringcare {
    variants {
        prod {
            applicationId = "com.watermelon.app"
        }
        dev {
            applicationId = "com.watermelon.app.dev"
        }
    }
}

BuildType Usage

android {
    defaultConfig {
        applicationId "com.watermelon.app"
    }
    buildTypes {
        release {
            applicationIdSuffix ".release"
        }
        debug {
            applicationIdSuffix ".debug"
        }
    }
}
apply plugin: StringCare
stringcare {
    variants {
        debug {
            applicationId = "com.watermelon.app.debug"
        }
        release {
            applicationId = "com.watermelon.app.release"
        }
    }
}

Clone this wiki locally