From 463d9ec4b4b354b795b056323d4e09ae44f65914 Mon Sep 17 00:00:00 2001 From: Max Date: Sun, 7 Jan 2024 10:14:19 +0800 Subject: [PATCH] =?UTF-8?q?=E5=90=8C=E6=AD=A5hiyoo=E6=B7=B7=E6=B7=86?= =?UTF-8?q?=E9=85=8D=E7=BD=AE=EF=BC=9A=E5=A2=9E=E5=8A=A0aabResGuard?= =?UTF-8?q?=E4=B8=8Exml-class-guard=E4=BE=9D=E8=B5=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- aab-res-guard-mapping.txt | 0 app/build.gradle | 31 ++++++++++++++++++++++++++++++- build.gradle | 4 ++++ xml-class-mapping.txt | 1 + 4 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 aab-res-guard-mapping.txt create mode 100644 xml-class-mapping.txt diff --git a/aab-res-guard-mapping.txt b/aab-res-guard-mapping.txt new file mode 100644 index 000000000..e69de29bb diff --git a/app/build.gradle b/app/build.gradle index c2035fdc0..bd153db04 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -4,7 +4,8 @@ apply plugin: 'com.google.firebase.crashlytics' apply plugin: 'kotlin-android' apply plugin: 'com.tencent.vasdolly' apply from: '../mob.gradle' - +apply plugin: "com.bytedance.android.aabResGuard" +apply plugin: "xml-class-guard" def onlyArm64 = Boolean.parseBoolean(only_arm64) android { @@ -319,3 +320,31 @@ channel { //低内存模式(仅针对V2签名,默认为false):只把签名块、中央目录和EOCD读取到内存,不把最大头的内容块读取到内存,在手机上合成APK时,可以使用该模式 lowMemory = false } + +aabResGuard { + mappingFile = file("aab-res-guard-mapping.txt").toPath() // Mapping file used for incremental obfuscation + whiteList = [ // White list rules + "*.R.raw.*", + "*.R.drawable.icon" + ] + obfuscatedBundleFileName = "duplicated-app.aab" // Obfuscated file name, must end with '.aab' + mergeDuplicatedRes = true // Whether to allow the merge of duplicate resources + enableFilterFiles = false // Whether to allow filter files + filterList = [ // file filter rules +// "*/arm64-v8a/*", +// "META-INF/*" + ] + + enableFilterStrings = false // switch of filter strings + unusedStringPath = file("unused.txt").toPath() // strings will be filtered in this file + languageWhiteList = ["en", "zh"] // keep en,en-xx,zh,zh-xx etc. remove others. +} + +//以下均为非必须 +xmlClassGuard { + findAabConstraintReferencedIds = true + //用于增量混淆的 mapping 文件 + mappingFile = file("xml-class-mapping.txt") + //更改manifest文件的package属性,即包名 + packageChange = ["com.yizhuan.erban": "com.c.r"] +} \ No newline at end of file diff --git a/build.gradle b/build.gradle index 117dd1166..c08e5b1b4 100644 --- a/build.gradle +++ b/build.gradle @@ -10,11 +10,13 @@ buildscript { repositories { mavenCentral() + jcenter() google() maven { url 'https://maven.aliyun.com/repository/public' } maven { url 'https://jitpack.io' } maven { url "https://mvn.mob.com/android" } maven { url 'https://repo1.maven.org/maven2/' } + maven { url 'https://raw.githubusercontent.com/martinloren/AabResGuard/mvn-repo' } } dependencies { @@ -27,6 +29,8 @@ buildscript { classpath "com.mob.sdk:MobSDK:2018.0319.1724" classpath 'com.google.gms:google-services:4.3.13' classpath 'com.google.firebase:firebase-crashlytics-gradle:2.9.2' + classpath "com.bytedance.android:aabresguard-plugin:0.1.10" + classpath "com.github.liujingxing:XmlClassGuard:1.2.6" } } diff --git a/xml-class-mapping.txt b/xml-class-mapping.txt new file mode 100644 index 000000000..542045815 --- /dev/null +++ b/xml-class-mapping.txt @@ -0,0 +1 @@ +class mapping: \ No newline at end of file