标签:index shrink 自动 微软 r文件 doc 指定 abr 资源文件
apply plugin: ‘com.android.application‘
apply plugin: ‘AndResGuard‘ //应用AndResGuard插件
buildscript {
repositories {
jcenter()
}
dependencies {
classpath ‘com.tencent.mm:AndResGuard-gradle-plugin:1.2.13‘ //添加AndResGuard依赖
}
}
android {
signingConfigs { //配置签名信息,注意,要放在buildTypes之前
release {
storeFile file("../keystore/bea.keystore") //签名文件位置,【.】代表当前目录,【..】代表父目录
storePassword "beachinambk"
keyAlias "bea.keystore"
keyPassword "beachinambk"
v2SigningEnabled true
}
debug {
storeFile file("../keystore/debug.keystore")
}
}
buildTypes {
release { //配置构建选项
minifyEnabled true
proguardFiles getDefaultProguardFile(‘proguard-android.txt‘), ‘proguard-rules.pro‘
shrinkResources true
zipAlignEnabled true
pseudoLocalesEnabled true
signingConfig signingConfigs.release //签名文件
}
}
}
//-----------------------------配置 AndResGuard-----------------------------
andResGuard {
mappingFile = null // = file("./resource_mapping.txt") //用于keep住资源的路径的mapping文件所在路径
use7zip = true //启用压缩。为true时,useSign必须为true
useSign = true // 启用签名。为true时,需要配置signConfig
keepRoot = false // 为true时,会keep住所有资源的原始路径,只混淆资源的名字
whiteList = [ //白名单,支持通配符,【+】代表1个或多个,【?】代表0个或1个,【*】代表0个或多个
"R.mipmap.ic_launcher", "R.drawable.icon",// for your icon
"R.string.com.crashlytics.*",// for fabric,详见https://docs.fabric.io/android/crashlytics/build-tools.html
"R.string.google_app_id",// for google-services
"R.id.*",//任意id
]
compressFilePattern = [ //需要压缩的文件的匹配规则,一般这里不需要动。支持 ? + * 通配符
"*.png",
"*.jpg",
"*.jpeg",
"*.gif",
"resources.arsc"
]
sevenzip { //配置7Zip,只需设置 artifact 或 path;支持同时设置,但此时以 path 的值为优先
artifact = ‘com.tencent.mm:SevenZip:1.2.13‘
//path = "/usr/local/bin/7za" //path指本地安装的7za(7zip命令行工具)
}
// finalApkBackupPath = "${project.rootDir}/final.apk" //可选,指定生成的apk的保存路径
// digestalg = "SHA-256" //可选: 指定v1签名时生成jar文件的摘要算法,默认值为“SHA-1”
}
apply plugin: ‘com.android.application‘
apply plugin: ‘AndResGuard‘ //应用AndResGuard插件
buildscript {
repositories {
jcenter()
}
dependencies {
classpath ‘com.tencent.mm:AndResGuard-gradle-plugin:1.2.13‘ //添加AndResGuard依赖
}
}
android {
signingConfigs { //配置签名信息,注意,要放在buildTypes之前
release {
storeFile file("../keystore/bea.keystore") //签名文件位置,【.】代表当前目录,【..】代表父目录
storePassword "beachinambk"
keyAlias "bea.keystore"
keyPassword "beachinambk"
v2SigningEnabled true
}
debug {
storeFile file("../keystore/debug.keystore")
}
}
buildTypes {
release { //配置构建选项
minifyEnabled true
proguardFiles getDefaultProguardFile(‘proguard-android.txt‘), ‘proguard-rules.pro‘
shrinkResources true
zipAlignEnabled true
pseudoLocalesEnabled true
signingConfig signingConfigs.release //签名文件
}
}
}
//-----------------------------配置 AndResGuard-----------------------------
andResGuard {
mappingFile = null // = file("./resource_mapping.txt") //用于keep住资源的路径的mapping文件所在路径
use7zip = true //启用压缩。为true时,useSign必须为true
useSign = true // 启用签名。为true时,需要配置signConfig
keepRoot = false // 为true时,会keep住所有资源的原始路径,只混淆资源的名字
whiteList = [ //白名单,支持通配符,【+】代表1个或多个,【?】代表0个或1个,【*】代表0个或多个
"R.mipmap.ic_launcher", "R.drawable.icon",// for your icon
"R.string.com.crashlytics.*",// for fabric,详见https://docs.fabric.io/android/crashlytics/build-tools.html
"R.string.google_app_id",// for google-services
"R.id.*",//任意id
]
compressFilePattern = [ //需要压缩的文件的匹配规则,一般这里不需要动。支持 ? + * 通配符
"*.png",
"*.jpg",
"*.jpeg",
"*.gif",
"resources.arsc"
]
sevenzip { //配置7Zip,只需设置 artifact 或 path;支持同时设置,但此时以 path 的值为优先
artifact = ‘com.tencent.mm:SevenZip:1.2.13‘
//path = "/usr/local/bin/7za" //path指本地安装的7za(7zip命令行工具)
}
// finalApkBackupPath = "${project.rootDir}/final.apk" //可选,指定生成的apk的保存路径
// digestalg = "SHA-256" //可选: 指定v1签名时生成jar文件的摘要算法,默认值为“SHA-1”
}
getResources().getIdentifier(“com.test.demo:drawable/icon”,null,null);//包名 : 资源文件夹名 / 资源名
getResources().getIdentifier(“icon”, “drawable”, “com.test.demo”);//ID名,资源属性,包名
getResources().getIdentifier(“com.test.demo:drawable/icon”,null,null);//包名 : 资源文件夹名 / 资源名
getResources().getIdentifier(“icon”, “drawable”, “com.test.demo”);//ID名,资源属性,包名
res path mapping:
res/mipmap-hdpi-v4 -> res/mipmap-hdpi-v4
res/mipmap-mdpi-v4 -> res/mipmap-mdpi-v4
res/mipmap-xhdpi-v4 -> res/mipmap-xhdpi-v4
res/mipmap-xxhdpi-v4 -> res/mipmap-xxhdpi-v4
res/mipmap-xxxhdpi-v4 -> res/mipmap-xxxhdpi-v4
res path mapping:
res/mipmap-hdpi-v4 -> res/mipmap-hdpi-v4
res/mipmap-mdpi-v4 -> res/mipmap-mdpi-v4
res/mipmap-xhdpi-v4 -> res/mipmap-xhdpi-v4
res/mipmap-xxhdpi-v4 -> res/mipmap-xxhdpi-v4
res/mipmap-xxxhdpi-v4 -> res/mipmap-xxxhdpi-v4
gradlew.bat resguardRelsese //Windows
./gradlew reguardRelease //OS X or Linux
gradlew.bat resguardRelsese //Windows
./gradlew reguardRelease //OS X or Linux
Backup Final APk(V2) to ***\Test\app\build\outputs\apk\release\app-release.apk
<--AndResGuard Done! You can find the output in ***\Test\app\build\outputs\apk\release\AndResGuard_app-release
Backup Final APk(V2) to ***\Test\app\build\outputs\apk\release\app-release.apk
<--AndResGuard Done! You can find the output in ***\Test\app\build\outputs\apk\release\AndResGuard_app-release
Backup Final APk(V2) to ***\Test\final.apk
<--AndResGuard Done! You can find the output in ***\Test\app\build\outputs\apk\release\AndResGuard_app-release
Backup Final APk(V2) to ***\Test\final.apk
<--AndResGuard Done! You can find the output in ***\Test\app\build\outputs\apk\release\AndResGuard_app-release
标签:index shrink 自动 微软 r文件 doc 指定 abr 资源文件
原文地址:https://www.cnblogs.com/baiqiantao/p/9292266.html