How Proguard works in Intellij Idea?

2019-04-29 16:41发布

I am using IntelliJ IDea 11.1.3 for Android development and I must admit it is a wonderful tool. I have few doubts about how to use Proguard with the IDE.

I have found the option of Run Progaurd under Open Module Settings -> Facets as in the image below

enter image description here

Run Proguard need a location of Config File which is defaulted to proguard-project.txt. Next is a check box which says Include system proguard file.

What System Proguard File is referred to in this checkbox option?

Given all the configuration of Proguard is in proguard-android.txt in Android SDK. How does proguard config works in the IntelliJ Idea?

P.S Any help will be highly appreciated I am trying to understand proguard with IntelliJ for almost a day now and having unsolved problems in another question.

2条回答
混吃等死
2楼-- · 2019-04-29 17:32

After spending two days trying to work Proguard 4.7 with IntelliJ Idea, I have following points to conclude

  1. It does not make any difference if you uncomment the line proguard.config=${sdk.dir}\tools\proguard\proguard-android.txt:proguard-project.txt in file project.properties.
  2. I not sure if IntelliJ reads the proguard-android.txt file located at android-sdk/tools/proguard
  3. IntelliJ idea reads the file proguard-project.txt files located in the project so suggestion is edit and place all your proguard configuration in this file.
  4. I am still not clear what does Include system proguard file checkbox option do.
查看更多
闹够了就滚
3楼-- · 2019-04-29 17:33

As per this google documentation http://developer.android.com/tools/help/proguard.html#enabling-gradle you need to change minifyEnabled false to minifyEnabled true in the projects build.gradle file.

...\app\proguard-rules.pro can be edited to add new rules if you need them. The default rules will probably do all you need, such as protect the names of methods that look like they might be invoked because of a layout xml onClick attribute. The document cited above also contains instructions for more complicated changes.

You will need to keep the mapping.txt file, which can be found under ...\app\build\outputs\mapping\release

查看更多
登录 后发表回答