简体   繁体   English

IntelliJ / Android Studio - 如何激活proguard来混淆代码 - 一步一步?

[英]IntelliJ / Android Studio - how to activate proguard to obfuscate code - step by step?

I was searching everywhere for answer, but did not find any. 我到处寻找答案,但没找到。

The main problem is that eveyone says about proguard configuration file, but there is none, IntelliJ / Android Studio does not generate such a file, there is none in SDK dir, so how do I generate valid configuration file for proguard obfuscation? 主要的问题是eveyone说有关proguard配置文件,但没有,IntelliJ / Android Studio不生成这样的文件,SDK目录中没有,所以如何为proguard混淆生成有效的配置文件?

I know i'm bit late in answering but here is the answer This blog contains all the stuff you need from the scratch step by step with images. 我知道我回答的时间有点迟了但是这里是答案这个博客包含了你需要从图像一步一步的所有东西。

  1. In android Studio open your project in Project view 在android Studio中,在Project视图中打开您的项目
  2. Open app's build.gradle file. 打开应用程序的build.gradle文件。
  3. Change 更改

minifyEnable false minifyEnable false

to

minifyEnable true minifyEnable是的

These are steps to enable the proguard. 这些是启用proguard的步骤。 If you want advance view then you can visit following link. 如果您想要提前查看,那么您可以访问以下链接。

Blogger have answered very briefly on this topic Blogger对此主题做了非常简短的回答

You have android-sdk\\tools\\proguard\\proguard-android.txt and proguard-android-optimize.txt. 你有android-sdk \\ tools \\ proguard \\ proguard-android.txt和proguard-android-optimize.txt。 Make sure you have "Android SDK Tools" installed with SDK Manager. 确保您已安装SDK Manager的“Android SDK工具”。 I think IntelliJ usually generates proguard-project.txt in the project directory. 我认为IntelliJ通常会在项目目录中生成proguard-project.txt。 If not, it's just a text file, so you can just add it to your project. 如果没有,它只是一个文本文件,所以你可以将它添加到你的项目中。 You set your custom rules in that file. 您在该文件中设置自定义规则。

You can even check the "Run ProGuard when building debug APK" in Project Structure window (F4): 您甚至可以在“项目结构”窗口(F4)中选中“在构建调试APK时运行ProGuard”:

在此输入图像描述

In Andoird Studio we cant see the proguard-rules.pro file in the Project tab by default. 在Andoird Studio中,默认情况下我们无法在“ 项目”选项卡中看到proguard-rules.pro文件。 to change this you can do the following: 要更改此设置,您可以执行以下操作:

  • Change the view to Project instead of Android : 将视图更改为Project而不是Android

改变观点

  • Now that you have done it you can view the proguard-rules.pro file inside yourproject/app/proguard-rules.pro . 既然你已经完成了它,你可以在你的项目/ app / proguard-rules.pro中查看proguard-rules.pro文件。 (see screenshot) (见截图)

见截图

The rest of the proguard configuration is traditional and you can find plenty of info by googling it. 其余的proguard配置是传统的,您可以通过Google搜索找到大量信息。 :) Hope it helps. :)希望它有所帮助。

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

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