android - 生成已签名的 apk 并激活 proguard 时,木材包不存在错误

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

我正在尝试使用 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 配置。有什么问题?

最佳答案

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

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

我应该使用这条线
  compile  "com.jakewharton.timber:timber:$TIMBER_VERSION"
okhttp3:logging-interceptor 也是如此,在更正前几行并编写了一些proguard规则之后,我已经生成了签名的apk。

关于android - 生成已签名的 apk 并激活 proguard 时,木材包不存在错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45030572/

相关文章:

自动检测信用卡类型的Android Edittext

git - 通过gradle在命令行上执行时如何转义双引号?

flutter - 错误 : downloads_path_provider in flutter

android - 基于 Web 服务的 Android 应用程序的测试策略

java - ActivityMonitor getHits() 不起作用

android - 查找Android中javaMaxHeapSize的默认值

android - 如何使用语音命令在 Google Glass 上启动应用程序

javascript - 我无法创建新项目 “Unable to resolve dependency for ':app @ debug/compileClasspath'”

gradle - 找不到或加载主类org.gradle.launcher.GradleMain

android-studio - 无法使用 VPN 和代理后面的 crashlytics 构建 Android 应用程序