Latest Solution
At first you should use shrinkResources true
instead of useProguard true
in android/app/build.gradle
.
In second instead of using proguard-android.txt
you should use proguard-android-optimize.txt
.
Read more in official Android documentations.
Read more about Android code shrink.
buildTypes {
release {
signingConfig signingConfigs.release
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
Following is newer version of proguard configuration rules to prevent logging and other retrofit protection:
# Flutter
-keep class io.flutter.app.** { *; }
-keep class io.flutter.plugin.** { *; }
-keep class io.flutter.util.** { *; }
-keep class io.flutter.view.** { *; }
-keep class io.flutter.** { *; }
-keep class io.flutter.plugins.** { *; }
# Retrofit
-keepattributes Signature
-keepattributes Exceptions
# OkHTTP
-dontwarn okhttp3.**
-keep class okhttp3.**{ *; }
-keep interface okhttp3.**{ *; }
# Other
-keepattributes *Annotation*
-keepattributes SourceFile, LineNumberTable
# Logging
-assumenosideeffects class android.util.Log {
public static *** d(...);
public static *** v(...);
public static *** i(...);
public static *** w(...);
public static *** e(...);
public static *** wtf(...);
}
-assumenosideeffects class io.flutter.Log {
public static *** d(...);
public static *** v(...);
public static *** w(...);
public static *** e(...);
}
-assumenosideeffects class java.util.logging.Level {
public static *** w(...);
public static *** d(...);
public static *** v(...);
}
-assumenosideeffects class java.util.logging.Logger {
public static *** w(...);
public static *** d(...);
public static *** v(...);
}
# Removes third parties logging
-assumenosideeffects class org.slf4j.Logger {
public *** trace(...);
public *** debug(...);
public *** info(...);
public *** warn(...);
public *** error(...);
}
To check it, install jadx
and open your_app.apk
and search inside of that about log
. You should have comparison between non-proguard .apk and proguard configured .apk log search result.
Without Proguard rules

With Proguard rules
