3

So in a few words ProGuard doesn't obfuscate sources when I build alternative buildType from Android Studio but works when I use "Generate Signed APK..." option to create apk file.

And some more details here: Android Studio 2.1.1, Gradle version: 2.10, plugin version .2.1.0

I've 3 build types with the following configuration:

buildTypes {
    release {
        minifyEnabled true
        ...
        proguardFile 'proguard-rules.pro'
        proguardFile getDefaultProguardFile('proguard-android.txt')
        signingConfig signingConfigs.release
    }
    releaseDebug {
        debuggable true
        minifyEnabled true
        ...
        proguardFile 'proguard-rules.pro'
        proguardFile getDefaultProguardFile('proguard-android.txt')
        signingConfig signingConfigs.release
    }
    debug {
        debuggable true
        minifyEnabled false
        ...
        proguardFile getDefaultProguardFile('proguard-android.txt')
        testProguardFile 'proguard-rules-test.pro'
        signingConfig signingConfigs.release
    }
}

I run application directly from Android Studio and have such results:

  • release - obfuscated
  • releaseDebug - NOT obfuscated
  • debug - not obfuscated

When I use "Generate Signed APK..." option:

  • release - obfuscated
  • releaseDebug - obfuscated
  • debug - not obfuscated

Is it a build system issue or I missed something?

P.S. Just for clarification, minifyEnabled is already enabled for releaseDebug build type and ProGuard is working but not in this particular case. This is not related to debug mode.

comrade
  • 4,590
  • 5
  • 33
  • 48
  • Possible duplicate of [Is it possible to use proguard in debug mode?](http://stackoverflow.com/questions/16559723/is-it-possible-to-use-proguard-in-debug-mode) – Ed Holloway-George Jun 30 '16 at 09:41
  • I'm sorry but not. ProGuard is working but not in one particular case. This is not related to debug mode. – comrade Jun 30 '16 at 09:45

1 Answers1

2

Finally, after some tests, I recognized that this issue is caused by debuggable true statement in releaseDebug configuration.

So Android Studio (or Gradle) will not use ProGuard obfuscation if you use debuggable true and minifyEnabled true statements in your alternative build type.

comrade
  • 4,590
  • 5
  • 33
  • 48