简体   繁体   中英

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?

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
  2. Open app's build.gradle file.
  3. Change

minifyEnable false

to

minifyEnable true

These are steps to enable the proguard. If you want advance view then you can visit following link.

Blogger have answered very briefly on this topic

You have android-sdk\\tools\\proguard\\proguard-android.txt and proguard-android-optimize.txt. Make sure you have "Android SDK Tools" installed with SDK Manager. I think IntelliJ usually generates proguard-project.txt in the project directory. 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):

在此输入图像描述

In Andoird Studio we cant see the proguard-rules.pro file in the Project tab by default. to change this you can do the following:

  • Change the view to Project instead of Android :

改变观点

  • Now that you have done it you can view the proguard-rules.pro file inside yourproject/app/proguard-rules.pro . (see screenshot)

见截图

The rest of the proguard configuration is traditional and you can find plenty of info by googling it. :) Hope it helps.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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