0

I am trying to test my app which has passed the 64K limit.

I have set minify on but it doesn't work when debuggable is enabled. However, if I build a version with debuggable off then it shrinks it by 2/3!

Am I missing something? This is the relevant part of my Gradle file:

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

proguard-rules.pro:

    -keep class .R
-keep class **.R$* {
    <fields>;
}
-keepattributes *Annotation*
-keepclassmembers class ** {
    @org.greenrobot.eventbus.Subscribe <methods>;
}
-keep enum org.greenrobot.eventbus.ThreadMode { *; }

-keepclassmembers class * extends org.greenrobot.eventbus.util.ThrowableFailureEvent {
    <init>(java.lang.Throwable);
}

-dontwarn com.google.**
-dontwarn com.squareup.picasso.**


-dontnote com.google.**
-dontnote com.squareup.picasso.**
Cœur
  • 37,241
  • 25
  • 195
  • 267
theblitz
  • 6,683
  • 16
  • 60
  • 114

1 Answers1

0

With proguard enabled your code gets obfuscated and debugging will not be possible. That is why when you want to debug and set the flag true, proguard does not activate and that is why you do not see the minification of your apk.

Check this post. It has a similar question and will help you understand the conditions better.

Community
  • 1
  • 1
Viral Patel
  • 32,418
  • 18
  • 82
  • 110
  • I actually looked at that post before asking. I got the impression that it implied that they can be mixed. The annoying thing is that after shrinking there are less than 29K methods. Most of the dropped ones are from google. – theblitz May 10 '16 at 12:03
  • The other thing I noticed is that this only happens when I run directly to the device. If I build it (using Build->Build APK) then the minify does work. – theblitz May 10 '16 at 12:17