Is it possible to use proguard in debug mode?

If you want to make the whole build process easier for you, you should switch over to gradle and Android Studio IDE.

Then you could easily add the following to your build.gradle file to run ProGuard:

android {
    buildTypes {
        release {
        }
        debug {
            minifyEnabled true
            proguardFile 'proguard-android.txt'
            zipAlignEnabled true
        }
    }
}

This will run ProGuard on your debug build, configured with the file “proguard-android.txt”, which should be put at your project’s root folder. And in addition your apk is being zip aligned (Just remove “zipAlignEnabled true”, if you don’t want that to happen). If you want to do the same for your release build, just add those three lines under “release”.

Slightly off-topic: Stuff like adding dependencies, signing your apk or adding other custom tasks to your build process is also way more uncomplicated with gradle. In addition you’ll be able to not only build your apk via Android Studio IDE, but also via a simple command on the command line (e.g. ./gradlew assembleDebug). So if you are working on a team, the setup process for new members is just one “./gradlew assembleDebug” away. Without the need for any IDE configuration at all. Importing your project including all dependencies is as simple as a one-click process

EDIT:
As of Gradle Android Build Tools version 0.14.0 the property names have changed (http://tools.android.com/tech-docs/new-build-system):

  • BuildType.runProguard -> minifyEnabled
  • BuildType.zipAlign -> zipAlignEnabled

I’ve updated the above code.

Leave a Comment