apply plugin: "xml-class-guard" 类混淆
apply from: 'and_res_guard.gradle' 资源混淆
类混淆
xmlClassGuard { /* * 是否查找约束布局的constraint_referenced_ids属性的值,并添加到AabResGuard的白名单中, * 是的话,要求你在XmlClassGuard前依赖AabResGuard插件,默认false */ findAabConstraintReferencedIds = false /* * 是否查找约束布局的constraint_referenced_ids属性的值,并添加到AndResGuard的白名单中, * 是的话,要求你在XmlClassGuard前依赖AndResGuard插件,默认false */ findAndConstraintReferencedIds = false //用于增量混淆的 mapping 文件 mappingFile = file("xml-class-mapping.txt") }
资源混淆
apply plugin: 'AndResGuard' andResGuard { // keep住不混淆的资源原有的物理路径 mappingFile = file("./resource_mapping.txt"); //如果混淆全部的话,设置 mappingFile = null mappingFile = null // 打开这个开关,会keep住所有资源的原始路径,只混淆资源的名字 keepRoot = false // 设置这个值,会把arsc name列混淆成相同的名字,减少string常量池的大小 // fixedResName = "arg" // 启用7zip压缩。当你使用v2签名的时候,7zip压缩是无法生效的。 // use7zip 为true时,useSign必须为true // 对于发布于 Google Play 的 APP,建议不要使用 7Zip 压缩,因为这个会导致 Google Play 的优化 Patch 算法失效 // 启用签名,(需要配置signConfig) useSign = true // 保留不被混淆的资源文件,只作用于文件名,不会对路径有影响,支持通配符:? * + // 【+】代表1个或多个,【?】代表0个或1个,【*】代表0个或多个。如 "R.id.*",//任意id whiteList = [ // for your icon "R.mipmap.icon_logo" ] // 打包时是否压缩这类文件,支持通配符:? * + compressFilePattern = [ "*.png", "*.jpg", "*.jpeg", "*.gif", //如果不是对APK size有极致的需求,请不要把resources.arsc添加进compressFilePattern //"resources.arsc" ] }
类文件以及资源文件 一起可改的
AndProguard/README.zh.md at master · EchoDongYu/AndProguard · GitHub