Skip to content

Assets Usage

Efra Espada edited this page Feb 10, 2022 · 5 revisions

Obfuscate any asset file you want.

Before starting, you'll need to configure the extensions not to be compressed. Don't forget to delete the app from your device first, otherwise, aaptOptions won't work:

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"]
}

App Usage

SC is designed to retrieve JSON objects, but you can use retrieve any file you want as ByteArray.

JSON Object

Java:

JSONObject json = SC.asset().json("config.json");

Kotlin:

val json = "config.json".json()

JSON Array

Java:

JSONArray json = SC.asset().jsonArray("configArray.json");

Kotlin:

val json = "configArray.json".jsonArray()

ByteArray

Java:

byte[] bytes = SC.asset().bytes("config.json");

Kotlin:

val bytes = "config.json".bytes()