shwenzhang / AndResGuard

proguard resource for Android by wechat team
Apache License 2.0
8.49k stars 1.53k forks source link

升级AGP 4.1之后,白名单失效 #436

Closed flymonkey00 closed 3 years ago

flymonkey00 commented 3 years ago

项目升级到AGP 4.1之后,whitelist中的资源同样会被混淆并能在mapping日志文件中找到混淆的记录

xDragonZ commented 3 years ago

Yes, same here, changing Gradle to version 6.7-rc-5 doesn't solve this too

Edit: looks like it's related to the packagename.R.?.?

leigao109 commented 3 years ago

我也有同样的问题,白名单失效, gradle版本为6.6.1

classpath 'com.android.tools.build:gradle:4.1.0'
classpath 'com.tencent.mm:AndResGuard-gradle-plugin:1.2.19'
getResources().getIdentifier("XXX", "drawable", this.getPackageName()) = 0

用1.2.18的版本也一样。

flymonkey00 commented 3 years ago

花了点时间快速看了一眼,应该是由于AGP 4.1 DslInfo 中的 applicationId 类型由 String 变为了 Property 导致 whiteListFullName 算的有问题。可以改一行代码简单支持下。

diff --git a/AndResGuard-gradle-plugin/src/main/groovy/com/tencent/gradle/AndResGuardTask.groovy b/AndResGuard-gradle-plugin/src/main/groovy/com/tencent/gradle/AndResGuardTask.groovy
index 7eb164a..7006edc 100644
--- a/AndResGuard-gradle-plugin/src/main/groovy/com/tencent/gradle/AndResGuardTask.groovy
+++ b/AndResGuard-gradle-plugin/src/main/groovy/com/tencent/gradle/AndResGuardTask.groovy
@@ -6,6 +6,7 @@ import com.tencent.mm.resourceproguard.InputParam
 import com.tencent.mm.resourceproguard.Main
 import org.gradle.api.DefaultTask
 import org.gradle.api.GradleException
+import org.gradle.api.provider.Property
 import org.gradle.api.tasks.TaskAction

 /**
@@ -58,7 +59,7 @@ class AndResGuardTask extends DefaultTask {
           buildConfigs << new BuildInfo(
               outputFile,
               variantInfo.signingConfig,
-              variantInfo.applicationId,
+              variantInfo.applicationId instanceof Property ? variantInfo.applicationId.get() : variantInfo.applicationId,
               variant.buildType.name,
               variant.productFlavors,
               variantName,
zhuangjiahua commented 3 years ago

同样问题,求解决!

fengxin0210fx commented 3 years ago

同问

fengxin0210fx commented 3 years ago

同问

donglua commented 3 years ago

+1

Suki-VT commented 3 years ago

The same problem, could you please fix it ASAP?

chancey0222 commented 3 years ago

我将AGP改成4.0.0就可以了