Android Studio Proguard 基地位置

Android Studio Proguard Base location

我正在使用 Zelix Klass Master 来混淆我的 android 应用程序。已经使用它大约 1 年了。我决定升级我的 android 工作室,因为我仍然是 运行 版本 3.0.1。更新 android studio 后,我无法再使用 Zelix 混淆我的 apk,它使用 Proguard 混淆我的 android 应用程序,Zelix 通过混淆器工作的方式是我需要替换目录中的混淆器 jar

<Android Studio>\gradle\m2repository\net\sf\proguard\proguard-base

我已经替换了目录中的所有 proguard jar,甚至删除了 sf 中的 proguard 父文件,它仍然使用 proguard 来混淆我的 android apk 我猜是吗不再使用来自 <Android Studio>\gradle\m2repository\net\sf\proguard 的混淆器,因为我删除了那个目录并且 android studio 仍然使用混淆器构建。

所以问题是新的 proguard 库在哪里?以及如何让它改用该目录(proguard-base)中的proguard? 有关如何设置 Zelix 的信息,您可以阅读 here:

编辑:在 Svet 的回答后,我尝试按照他的建议进行操作,但它现在抛出了这个错误..

Unable to find method 'proguard.KeepClassSpecification.(ZZZZZZZLproguard/ClassSpecification;Lproguard/ClassSpecification;)V'. Possible causes for this unexpected error include:

  • Gradle's dependency cache may be corrupt (this sometimes occurs after a network connection timeout.) Re-download dependencies and sync project (requires network)
  • The state of a Gradle build process (daemon) may be corrupt. Stopping all Gradle daemons may solve this problem. Stop Gradle build processes (requires restart)
  • Your project may be using a third-party plugin which is not compatible with the other plugins in the project or the version of Gradle requested by the project.
In the case of corrupt Gradle processes, you can also try closing the IDE and then killing all Java processes.

问题似乎是 ProGuard 现在被视为 Android Gradle 插件在最新版本的 Android Studio 中的依赖项,因此随着它。因此,用重命名的 proGuardStub.jar 替换 proguard.jar 可能会自动撤消。

我绝对不是 Gradle 专家。但是,有人告诉我像下面这样对 build.gradle 进行更改。

buildscript {  
    repositories {
        flatDir { dirs '/proguard' }
    }
    dependencies {
        classpath ':proguard:'
    }
}

"flatDir" 指定了一个我认为不会自动更新的平面目录存储库。如果有 Gradle 专家可以改进或详细说明这种方法,我们将不胜感激。

您收到 "Unable to find method 'proguard.KeepClassSpecification.(ZZZZZZZLproguard/ClassSpecification;Lproguard/ClassSpecification;)V" 错误表明您成功使用了重命名的 proguardStub.jar。问题是当前的 proguardStub.jar 需要更新以更全面地反映 ProGuard 6.0。看起来 ProGuard 6.0 添加了一个额外的构造函数,它没有出现在 proguardStub.jar.

中的 KeepClassSpecification class 中

您可以合理地期待 proguardStub.jar 在下周左右发布新版本。

好的,感谢 Svet,我已经解决了这个问题。我会奖励他帮助我的赏金。所以他回答并告诉我我必须像下面这样更改混淆器类路径

buildscript {  
    repositories {
        flatDir { dirs '/proguard' }
    }
    dependencies {
        classpath ':proguard:'
    }
}

在那之后显然它不能与原来的 proguardStub.jar 一起使用,因为它是用于 proguard 5.0 而不是 6.0.3 我将代码拆开并将代码注入旧的 proguardStub.jar视为 6.0.3,现在终于可以使用了!这是我创建的更新 proguardStub.jar here

如果你们中有人想知道我是怎么做到的,我只是使用 ASM 更改了字节码,这样它就不会导致错误,并且还更改了旧字符串,因此它显示 6.0.3 而不是 5.0 :) 当然字符串不影响任何东西,而只是显示它是什么版本。