The below code is my config for remove Logcat
in debug mode using Proguard
follow some post here, here, here but it not work. My Logcat
is still display.
What do I do wrong here?
Another question is I see some person suggest another way for remove log is create a custom LogcatUtils class like this, or use Timber so I wonder if Proguard
can remove Logcat
or not ?
I still prefer remove Logcat completely because I think it may reduce the APK size.
Any help or suggestion would be appreciated.
My build.grade
buildTypes {
debug {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
proguard-rules.pro
-assumenosideeffects class android.util.Log {
public static boolean isLoggable(java.lang.String, int);
public static int v(...);
public static int i(...);
public static int w(...);
public static int d(...);
public static int e(...);
}
Activity code
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
for(int i = 0; i < 20; i++) {
Log.d("TAG", "hehe");
}
}
}
I have tested it on emulator with Build Variant = debug DEMO PROJECT: https://drive.google.com/file/d/0B_poNaia6t8kSTRMV2cxUjlaSDA/view?usp=sharing