我正在尝试使用 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/