Is it possible to use proguard in debug mode?

前端 未结 5 1022
时光取名叫无心
时光取名叫无心 2020-12-01 10:26

In my android app, i want to test some features with proguard on.

I don\'t need to really \"debug\" it, but i want proguard to run when i hit run in eclipse. I don\'

5条回答
  •  离开以前
    2020-12-01 10:37

    Old Answer :

    http://developer.android.com/tools/help/proguard.html

    ProGuard runs only when you build your application in release mode, so you do not have to deal with obfuscated code when you build your application in debug mode.

    When you build your application in release mode, either by running ant release or by using the Export Wizard in Eclipse, the build system automatically checks to see if the proguard.config property is set. If it is, ProGuard automatically processes the application's bytecode before packaging everything into an .apk file. Building in debug mode does not invoke ProGuard, because it makes debugging more cumbersome.

    Update: 13-3-2016

    It is possible with the new gradle build system. You need to set minifyEnabled to true in your build.gradle file. Generally you have pro-guard running in release mode. There are other options available like shrinking resources. You can find some useful info @ http://tools.android.com/tech-docs/new-build-system

    Also do have a look @

    http://developer.android.com/tools/building/configuring-gradle.html

     android {
       ...
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
         debug {
    
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
       }
     }
    

提交回复
热议问题