简体   繁体   English

Android Studio Proguard Base位置

[英]Android Studio Proguard Base location

I'm using Zelix Klass Master to obfuscate my android apps. 我正在使用Zelix Klass Master来混淆我的android应用程序。 Been using It for about 1 year. 使用它大约一年了。 I decided to upgrade my android studio since I was still running version 3.0.1. 由于我仍在运行3.0.1版,因此我决定升级android studio。 After updating android studio I can no longer obfuscate my apk with Zelix, It's using Proguard to obfuscate my android application the way Zelix works via proguard is that I need to replace the proguard jar inside the directory 更新android studio后,我无法再使用Zelix来混淆我的apk,它使用Proguard来混淆我的android应用程序,而Zelix通过proguard的工作方式是我需要替换目录中的proguard jar

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

I have replaced all the proguard jars in the directory and even delated the proguard parent file inside sf and it still uses proguard to obfuscate my android apk my guess is it no longer uses proguard from <Android Studio>\\gradle\\m2repository\\net\\sf\\proguard because I deleted that directory and android studio still builds using proguard. 我已经替换了目录中的所有proguard jar,甚至在sf引用了proguard父文件,它仍然使用proguard来混淆我的android apk,我猜是它不再使用<Android Studio>\\gradle\\m2repository\\net\\sf\\proguard proguard <Android Studio>\\gradle\\m2repository\\net\\sf\\proguard因为我删除了该目录,而android studio仍然使用proguard进行构建。

So the question is where is the new proguard lib? 所以问题是新的proguard库在哪里? and how do I get it to use proguard from that directory (proguard-base) instead? 以及如何从该目录(proguard-base)中使用proguard? for information about how to setup Zelix you can read it here : 有关如何设置Zelix的信息,可以在这里阅读:

Edit: After Svet's answer I tried doing what he suggested and it's throwing this error now.. 编辑:在Svet的回答后,我尝试做他建议的操作,并且现在抛出此错误。

Unable to find method 'proguard.KeepClassSpecification.(ZZZZZZZLproguard/ClassSpecification;Lproguard/ClassSpecification;)V'. 无法找到方法'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) Gradle的依赖项缓存可能已损坏(这有时会在网络连接超时后发生。)重新下载依赖项并同步项目(需要网络)
  • The state of a Gradle build process (daemon) may be corrupt. Gradle构建过程(守护程序)的状态可能已损坏。 Stopping all Gradle daemons may solve this problem. 停止所有Gradle守护程序可以解决此问题。 Stop Gradle build processes (requires restart) 停止Gradle构建过程(需要重新启动)
  • 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. 您的项目可能使用的第三方插件与该项目中的其他插件或该项目要求的Gradle版本不兼容。
In the case of corrupt Gradle processes, you can also try closing the IDE and then killing all Java processes. 如果Gradle进程损坏,您也可以尝试关闭IDE,然后终止所有Java进程。

The problem appears to be the fact that ProGuard is now treated as a dependency of the Android Gradle plugin in the latest versions of Android Studio and so is updated along with it. 问题似乎是因为ProGuard现在在最新版本的Android Studio中被视为Android Gradle插件的依赖项,因此也随之更新。 So any replacement of the proguard.jar with the renamed proGuardStub.jar may being automatically reversed. 因此,用重命名的proGuardStub.jar替换proguard.jar可能会自动撤消。

I am definitely not a Gradle expert. 我绝对不是Gradle专家。 However, I am told that a change to the build.gradle like the following works. 但是,有人告诉我,对build.gradle的更改类似于以下工作。

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

The "flatDir" specifies a flat directory repository which I believe will not be automatically updated. “ flatDir”指定一个平面目录存储库,我相信它不会自动更新。 If there are any Gradle experts out there who can improve or elaborate on this approach then it would be greatly appreciated. 如果有任何Gradle专家可以改进或详细说明这种方法,那么将不胜感激。

The fact that you are getting the "Unable to find method 'proguard.KeepClassSpecification.(ZZZZZZZLproguard/ClassSpecification;Lproguard/ClassSpecification;)V" error suggests that you are successfully using the renamed proguardStub.jar. 您收到“无法找到方法'proguard.KeepClassSpecification。(ZZZZZZZLproguard / ClassSpecification; Lproguard / ClassSpecification;)V”错误的事实,表明您已成功使用重命名的proguardStub.jar。 The problem is that the current proguardStub.jar needs to be updated to more fully reflect ProGuard 6.0. 问题是需要更新当前的proguardStub.jar以更全面地反映ProGuard 6.0。 It looks like ProGuard 6.0 adds an extra constructor which does not appear in the KeepClassSpecification class in proguardStub.jar. 看起来ProGuard 6.0添加了一个额外的构造函数,该构造函数不会出现在proguardStub.jar的KeepClassSpecification类中。

You could reasonably expect a new release of proguardStub.jar in the next week or so. 您可以合理预期下一周左右会发布新的proguardStub.jar。

Okay, I have fixed the issue thanks to Svet. 好的,感谢Svet,我已解决了此问题。 I will reward him the bounty for helping me. 我将奖励他帮助我的赏金。 So He answered and told me I had to change the proguard classPath like the following 因此,他回答并告诉我,我必须像下面这样更改proguard classPath

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

After that obviously It won't work with the original proguardStub.jar since It's for proguard 5.0 and not 6.0.3 I am taken the code apart and injected code into the old proguardStub.jar to be treated as 6.0.3 and now it finally works! 在那之后,显然它不能与原始的proguardStub.jar一起使用,因为它是针对proguard 5.0而不是6.0.3的,我将代码分开,并将代码注入到旧的proguardStub.jar中,视为6.0.3,现在终于作品! here is the updated proguardStub.jar that I have created here . 这是我在这里创建的更新后的proguardStub.jar。

If any of you are wondering how I did it, I just changed the bytecode using ASM so it doesn't cause errors and also changed the old String so it shows 6.0.3 instead of 5.0 :) Of course the String doesn't effect anything rather then just showing what version it is. 如果您想知道我是如何做到的,我只是使用ASM更改了字节码,因此它不会导致错误,还更改了旧的String,因此它显示6.0.3而不是5.0 :)当然,String无效而不是仅仅显示它的版本。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM