Skip to content

Implementation

Efra Espada edited this page Jun 23, 2021 · 28 revisions

Gradle support

Some Gradle 6.x versions don't work properly. Set v6.4.1 in your gradle-wrapper.properties:

distributionUrl=https\://services.gradle.org/distributions/gradle-6.4.1-all.zip 

Plugin setup

The plugin looks for string resources for obfuscating at compilation time. Works globally in the project.

In the project's root-level:

buildscript { ext.stringcare_version = '4.2.1' repositories { google() mavenCentral() } dependencies { classpath "io.github.stringcare:plugin:$stringcare_version" classpath 'com.android.tools.build:gradle:4.2.1' } }

Library setup

The library reveals the obfuscated string resources generated by the plugin and obfuscates and reveals strings at runtime.

In app module:

apply plugin: 'com.android.application' apply plugin: StringCare // default config stringcare { debug false assetsFiles = ["*.json"] stringFiles = ['strings.xml'] srcFolders = ['src/main'] } android { // any config compileOptions { sourceCompatibility 1.8 targetCompatibility 1.8 } } dependencies { implementation "io.github.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()); }
override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) SC.init { applicationContext } }
Clone this wiki locally