【问题标题】:Timber package doesn't exist Error when generating signed apk and proguard is activated生成已签名的 apk 并激活 proguard 时,木材包不存在错误
【发布时间】:2017-07-11 09:29:15
【问题描述】:

我正在尝试使用 android studio 生成一个签名的 apk,它给了我这些错误

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

在我的应用程序类中,我将 Timber 定义如下

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

这是我使用的 Okhttp 日志记录方法:

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

gradle 设置如下:

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

并且没有特定的 proguard 配置。有什么问题?

【问题讨论】:

    标签: android gradle android-gradle-plugin apk timber-android


    【解决方案1】:

    所以我发现了导致此问题的问题,在 build.gradle 应用程序模块文件中,我选择了 debugCompile 而不是常规的 compileso 而不是

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

    我应该使用这条线

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

    okhttp3:logging-interceptor 也是如此,在更正前面的行并编写了一些 proguard 规则之后,我已经生成了签名的 apk。

    【讨论】:

      猜你喜欢
      • 2018-04-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-06-12
      • 2020-08-02
      • 1970-01-01
      • 1970-01-01
      • 2019-05-01
      相关资源
      最近更新 更多