1

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.

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
Shahbaz Hussain
  • 542
  • 4
  • 21

1 Answers1

2

I think on Timber has use Log. You can try it add Timber with Log on proguard-rules.pro

# Remove log
-assumenosideeffects class android.util.Log {
public static boolean isLoggable(java.lang.String, int);
public static int d(...);
public static int w(...);
public static int v(...);
public static int i(...);
public static int e(...);
}

-assumenosideeffects class timber.log.Timber* {
public static *** d(...);
public static *** w(...);
public static *** v(...);
public static *** i(...);
public static *** e(...);
}
Nguyễn Trung Hiếu
  • 2,004
  • 1
  • 10
  • 22