使用AndResGuard 混淆apk资源文件
Github库,微信团队开源项目
·
Github库,微信团队开源项目
在project的build.gradle中添加
buildscript
{
repositories {
jcenter()
}
dependencies {
classpath 'com.tencent.mm:AndResGuard-gradle-plugin:1.2.13'
}
}
repositories {
jcenter()
}
dependencies {
classpath 'com.tencent.mm:AndResGuard-gradle-plugin:1.2.13'
}
}
在module的build.gradle中添加
apply
plugin
:
'AndResGuard'
andResGuard
{
// mappingFile = file("./resource_mapping.txt")
mappingFile = null
use7zip = true
useSign = true
// it will keep the origin path of your resources when it's true
keepRoot = false
whiteList = [
// your icon
"R.drawable.icon" ,
// for fabric
"R.string.com.crashlytics.*" ,
// for google-services
"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"
]
compressFilePattern = [
"*.png" ,
"*.jpg" ,
"*.jpeg" ,
"*.gif" ,
]
sevenzip {
artifact = 'com.tencent.mm:SevenZip:1.2.13'
//path = "/usr/local/bin/7za"
}
/**
* Optional: if finalApkBackupPath is null, AndResGuard will overwrite final apk
* to the path which assemble[Task] write to
**/
// finalApkBackupPath = "${project.rootDir}/final.apk"
/**
* Optional: Specifies the name of the message digest algorithm to user when digesting the entries of JAR file
* Only works in V1signing, default value is "SHA-1"
**/
// digestalg = "SHA-256"
}
// mappingFile = file("./resource_mapping.txt")
mappingFile = null
use7zip = true
useSign = true
// it will keep the origin path of your resources when it's true
keepRoot = false
whiteList = [
// your icon
"R.drawable.icon" ,
// for fabric
"R.string.com.crashlytics.*" ,
// for google-services
"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"
]
compressFilePattern = [
"*.png" ,
"*.jpg" ,
"*.jpeg" ,
"*.gif" ,
]
sevenzip {
artifact = 'com.tencent.mm:SevenZip:1.2.13'
//path = "/usr/local/bin/7za"
}
/**
* Optional: if finalApkBackupPath is null, AndResGuard will overwrite final apk
* to the path which assemble[Task] write to
**/
// finalApkBackupPath = "${project.rootDir}/final.apk"
/**
* Optional: Specifies the name of the message digest algorithm to user when digesting the entries of JAR file
* Only works in V1signing, default value is "SHA-1"
**/
// digestalg = "SHA-256"
}
需要生成Release安装包的话还需要添加
signingConfigs { config { keyAlias '别名' keyPassword '' storeFile file('keystore路径') storePassword '' } }
buildTypes { release { minifyEnabled
true shrinkResources
true proguardFiles getDefaultProguardFile(
'proguard-android.txt'),
'proguard-rules.pro' signingConfig
signingConfigs.
config } }
在Terminal中运行
gradlew resguardRelease 即可生成apk
不指定生成路径的话会默认覆盖到
assemble的生成路径
可以在
build
|_outputs
|_apk
|_release
|_AndResGuard_app-release
中找到生成的安装包,一般xxx_7zip_aligned_signed.apk就是混淆后的安装包
更多推荐
已为社区贡献1条内容
所有评论(0)