I am using Timber logs for logging in my Android application only in the Debug environment, for that purpose, I added this line in my Application class:-
if (BuildConfig.DEBUG) {
Timber.plant(new Timber.DebugTree());
}
I, subsequently, used this throughout my application flawlessly. Also, I obfuscated the Timber logs for release build variant, by adding these lines to my proguard-rules.pro
file:-
-assumenosideeffects class timber.log.Timber* {
public static *** v(...);
public static *** d(...);
public static *** i(...);
public static *** e(...);
public static *** w(...);
}
In my app's build.gradle
, I added this:
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
Despite, all of this in my production app, I got a crash through Crashlytics caused for a NullPointerException inside one of the Timber log statement, the Timber log, first of all, shouldn't have been there in the production app, as I've stripped it down, moreover, I've planted Timber log only in the debug environment, so I don't understand why it'snot stripped down.