Search code examples
androidgradleandroid-gradle-pluginapktimber-android

Timber package doesn't exist Error when generating signed apk and proguard is activated


I'm trying to generate a signed apk with android studio, it gives me these errors

Error:(59, 18) error: package timber.log does not exist
Error:(27, 23) error: package okhttp3.logging does not exist

in my application class I define Timber as follow

if (BuildConfig.DEBUG) {
    Timber.plant(new Timber.DebugTree());
} else {
    Timber.plant(new CrashReportingTree());
}

and this is the Okhttp logging method I use:

public static HttpLoggingInterceptor loggingInterceptor() {
return new HttpLoggingInterceptor().setLevel(BuildConfig.DEBUG ? HttpLoggingInterceptor.Level.BODY :HttpLoggingInterceptor.Level.NONE);
}

gradle setup as follow:

 release {
      minifyEnabled true
      shrinkResources true
      proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }

and there is no specific proguard configurations. what could be wrong?


Solution

  • So I found the problem that causing this issue, in build.gradle app module file I was choosing the debugCompile instead of the regular compileso instead of

      debugCompile  "com.jakewharton.timber:timber:$TIMBER_VERSION"
    

    I should use this line

      compile  "com.jakewharton.timber:timber:$TIMBER_VERSION"
    

    and the same for okhttp3:logging-interceptor, after correcting the previous lines, and writing some proguard rules, I've generated the signed apk.