Skip to content

Implementation

Efra Espada edited this page May 27, 2019 · 28 revisions

Plugin

Plugin for Android Studio which looks for string resources for obfuscating at compilation time. Works globally in the project.

If you are using variants, It's recommended to check out the configuration page for reading multiple directories, default configuration could be insufficient.

Add these lines in the build file in the project's root-level:

buildscript {
    ext.stringcare_version = '1.6'
    repositories {
        jcenter()
    }
    dependencies {
        classpath "com.stringcare:plugin:$stringcare_version"
        classpath "com.android.tools.build:gradle:3.4.1"
    }
}

apply plugin: StringCare

Library

The library reveals the obfuscated string resources previously by the plugin. Add this line in the build file of any module where you want to reveal obfuscated strings:

repositories {
    jcenter()
} 
 
dependencies {
    implementation "com.stringcare:library:$stringcare_version"
}

The plugin must work with the same version of the library.

Setup in code

The library needs the global application's context:

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    SC.init(getApplicationContext());
}

Additional tips

Android Studio can produce some compile errors If your release keystore is not defined. Run this on the Android Studio terminal:

Windows
gradlew.bat clean buildDebug -i
macOS
./gradlew clean buildDebug -i