-
-
Notifications
You must be signed in to change notification settings - Fork 42
Assets Usage
Efra Espada edited this page Sep 2, 2020
·
5 revisions
Obfuscate any asset file you want.
Before start, you'll need to configure the extensions not to be compressed:
android {
aaptOptions {
noCompress "json"
}
}
Select the files:
apply plugin: 'com.android.application'
apply plugin: StringCare
stringcare {
assetsFiles = ["test_a.json", "raw/cipher.txt"]
}
Or select a group of files:
apply plugin: 'com.android.application'
apply plugin: StringCare
stringcare {
assetsFiles = ["*.json"]
}
SC is designed to retrieve JSON objects, but you can use retrieve any file you want as ByteArray
.
Java:
JSONObject json = SC.asset().json("config.json");
// async
SC.asset().asyncJson("config.json", json -> {
// json
});
Kotlin:
val json = "config.json".json()
// async
"config.json".asyncJson { json ->
// json
}
Java:
JSONArray json = SC.asset().jsonArray("configArray.json");
// async
SC.asset().asyncJsonArray("configArray.json", json -> {
// json
});
Kotlin:
val json = "configArray.json".jsonArray()
// async
"configArray.json".asyncJsonArray { json ->
// json
}
Java:
byte[] bytes = SC.asset().bytes("config.json");
// async
SC.asset().asyncBytes("config.json", byteArray -> {
// byteArray
});
Kotlin:
val bytes = "config.json".bytes()
// async
"config.json".asyncBytes { bytes ->
val value = String(bytes)
}
You can use SC for retrive non-obfuscated files:
Java:
JSONObject json = SC.asset().json("config.json", false);
JSONArray json = SC.asset().jsonArray("configArray.json", false);
byte[] bytes = SC.asset().bytes("config.json", false);
Kotlin:
val json = "config.json".json { false }
val jsonArray = "configArray.json".jsonArray { false }
val bytes = "config.json".bytes { false }
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.