10

I am trying to remove the log statements without success. Other SO answers to the same question refer to Eclipse or to an old Android Studio IDE (Intellij).

build.gradle

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

proguard-rules.pro

-assumenosideeffects class android.util.Log {
    public static *** d(...);
    public static *** v(...);
    public static *** i(...);
    public static *** w(...);
    public static *** e(...);
}

I can still see the log statements after getting the source code from the signed app-release.apk

momo
  • 3,313
  • 2
  • 19
  • 37

1 Answers1

13

a change in the build.gradle, replacing the default proguard-android.txt with proguard-android-optimize.txt did the trick.

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

Note: the default proguard setting in gradle is proguard-android.txt

Roy Falk
  • 1,685
  • 3
  • 19
  • 45
momo
  • 3,313
  • 2
  • 19
  • 37
  • This really saved my day! This is actually mentioned here (indirectly): https://developer.android.com/studio/build/shrink-code.html#shrink-code – kirtan403 Jul 05 '16 at 18:48
  • after using proguard-android-optimize.txt i am getting error - java.lang.IllegalArgumentException: Form-encoded method must contain at least one @Field. – Aman Verma May 23 '17 at 12:18
  • What was your change?? This code looks exactly the same as the question.... – Johnathan Logan Aug 16 '17 at 04:56
  • 2
    @JohnathanLogan 'proguard-android.txt' to 'proguard-android-optimize.txt' – momo Aug 17 '17 at 07:33