-
-
Notifications
You must be signed in to change notification settings - Fork 42
Implementation
Efra Espada edited this page Jan 3, 2020
·
28 revisions
Plugin for Android Studio which 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.0.0'
repositories {
jcenter()
google()
mavenCentral()
maven {
url "https://plugins.gradle.org/m2/"
}
}
dependencies {
classpath "com.stringcare:plugin:$stringcare_version"
classpath 'com.android.tools.build:gradle:3.5.3'
}
}
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 {
// The library reveals the obfuscated string resources generated
// by the plugin and obfuscates and reveals strings at runtime:
implementation "com.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 }
}
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
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.