I use the below code in my proguard rules to strip out any log.d i may have left before i compile the release apk.
> -assumenosideeffects class android.util.Log {
> public static *** d(...);
> public static *** v(...); }
Is there a way to do it for all timber logs?
Timber.w("This shouldn't show in release apk when decompiled");
Would the same approach - but using a Timber
class instead of Log
- not work? E.g.:
-assumenosideeffects class timber.log.Timber* {
public static *** v(...);
public static *** d(...);
public static *** i(...);
}
Alternatively, you could follow the sample project and do something like:
public class App extends Application {
@Override
public void onCreate() {
super.onCreate();
if (BuildConfig.DEBUG) {
Timber.plant(new DebugTree());
} else {
Timber.plant(new ProductionTree());
}
}
private static class ProductionTree extends Timber.Tree {
@Override
protected void log(int priority, String tag, String message, Throwable t) {
// Do whatever (or nothing) here.
}
}
}