buildscript {ext.kotlin_version = "1.4.31"repositories {google()jcenter()maven {url "https://s01.oss.sonatype.org/content/repositories/snapshots/"}}dependencies {classpath "com.android.tools.build:gradle:7.2.2"classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
// classpath "com.bytedance.android:aabresguard-plugin:0.1.0"classpath 'io.github.leon406:AndResGuard-gradle-plugin:1.2.23'// NOTE: Do not place your application dependencies here; they belong// in the individual module build.gradle files}
}
在app目录下新建脚本and_res_guard.gradle
apply plugin: 'AndResGuard'andResGuard {//mappingFile = file("./resource_mapping.txt")mappingFile = nulluse7zip = trueuseSign = truekeepRoot = falsecompressFilePattern = ["*.png","*.jpg","*.jpeg","*.gif","*.xml","*.json","*.html",
// "assets.arsc","resources.arsc"]whiteList = [// your icon"R.mipmap.ic_launcher","R.mipmap.ic_launcher_round",// for fabric"R.string.com.crashlytics.*",// for umeng update"R.string.tb_*","R.layout.tb_*","R.drawable.tb_*","R.drawable.u1*","R.drawable.u2*","R.color.tb_*",// umeng share for sina"R.drawable.sina*",// for google-services.json"R.string.google_app_id","R.string.gcm_defaultSenderId","R.string.default_web_client_id","R.string.ga_trackingId","R.string.firebase_database_url","R.string.google_api_key","R.string.google_crash_reporting_api_key",//友盟"R.string.umeng*","R.string.UM*","R.layout.umeng*","R.drawable.umeng*","R.id.umeng*","R.anim.umeng*","R.color.umeng*","R.style.*UM*","R.style.umeng*",//融云"R.drawable.u*","R.drawable.rc_*","R.string.rc_*","R.layout.rc_*","R.color.rc_*","R.id.rc_*","R.style.rc_*","R.dimen.rc_*","R.array.rc_*"]sevenzip {artifact = 'com.tencent.mm:SevenZip:1.2.10'//path = "/usr/local/bin/7za"}/*** 可选: 如果不设置则会默认覆盖assemble输出的apk**///finalApkBackupPath = "${project.rootDir}/final.apk"
}