/**
* 资源文件混淆打包
*
* 更多用法参见:
* https://github.com/shwenzhang/AndResGuard
*
* 更多白名单如下:
* https://github.com/shwenzhang/AndResGuard/blob/master/doc/white_list.md
*
* 使用方法:
* classpath 'com.tencent.mm:AndResGuard-gradle-plugin:1.2.17'
* apply from: 'and_res_guard.gradle'
*/
apply plugin: 'AndResGuard'
andResGuard {
// mappingFile = file("./resource_mapping.txt")
mappingFile = null
use7zip = true //对于发布于Google Play的APP,建议不要使用7Zip压缩,因为这个会导致Google Play的优化Patch算法失效
useSign = true
// 打开这个开关,会keep住所有资源的原始路径,只混淆资源的名字
keepRoot = false
// 设置这个值,会把arsc name列混淆成相同的名字,减少string常量池的大小
fixedResName = "arg"
// 打开这个开关会合并所有哈希值相同的资源,但请不要过度依赖这个功能去除去冗余资源
mergeDuplicatedRes = true
//文件通配符
// ? Zero or one character
// * Zero or more of character
// + One or more of character
compressFilePattern = [
"*.png",
"*.jpg",
"*.jpeg",
"*.gif",
// "resources.arsc" 如果不是对APK size有极致的需求,请不要把resources.arsc添加进compressFilePattern
]
//添加第三方白名单
whiteList = [
// your icon
"R.drawable.icon",
// for fabric
"R.string.com.crashlytics.*",
// 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",
//for JPush
"R.drawable.jpush_notification_icon",
//Huawei push
"R.string.hms_*",
"R.string.connect_server_fail_prompt_toast",
"R.string.getting_message_fail_prompt_toast",
"R.string.no_available_network_prompt_toast",
"R.string.third_app_*",
"R.string.upsdk_*",
"R.style.upsdkDlDialog",
"R.style.AppTheme",
"R.style.AppBaseTheme",
"R.dimen.upsdk_dialog_*",
"R.color.upsdk_*",
"R.layout.upsdk_*",
"R.drawable.upsdk_*",
"R.drawable.hms_*",
"R.layout.hms_*",
"R.id.hms_*",
//GrowingIO
"R.string.growingio_project_id",
"R.string.growingio_url_scheme",
"R.string.growingio_channel",
//getui(个推)
"R.drawable.push",
"R.drawable.push_small",
"R.layout.getui_notification",
// Umeng sdk
"R.anim.umeng*",
"R.string.umeng*",
"R.string.UM*",
"R.string.tb_*",
"R.layout.umeng*",
"R.layout.socialize_*",
"R.layout.*messager*",
"R.layout.tb_*",
"R.color.umeng*",
"R.color.tb_*",
"R.style.*UM*",
"R.style.umeng*",
"R.drawable.umeng*",
"R.drawable.tb_*",
"R.drawable.sina*",
"R.drawable.qq_*",
"R.drawable.tb_*",
"R.id.umeng*",
"R.id.*messager*",
"R.id.progress_bar_parent",
"R.id.socialize_*",
"R.id.webView",
//融云
"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_*"
//环信
]
//配置7Zip
//在设置sevenzip时, 你只需设置artifact或path. 支持同时设置,总以path的值为优先.
sevenzip {
artifact = 'com.tencent.mm:SevenZip:1.2.10'
//path = "/usr/local/bin/7za"
}
/**
* 可选: 如果不设置则会默认覆盖assemble输出的apk
**/
// finalApkBackupPath = "${project.rootDir}/final.apk"
/**
* 可选: 指定v1签名时生成jar文件的摘要算法
* 默认值为“SHA-1”
**/
// digestalg = "SHA-256"
}