-
-
Notifications
You must be signed in to change notification settings - Fork 44
Implementation
Efra Espada edited this page Jun 23, 2021
·
28 revisions
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
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'
}
}
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.
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 }
}
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.