android - 生成签名 APK 时改造 2.3.0 错误

标签 android proguard retrofit2

我已经更新了 Retrofit v 2.3.0 和 okhttp 3.8.0 以及 okio 1.13.0 但是现在当我尝试生成签名的 APK 时我收到以下错误:

Warning:retrofit2.OkHttpCall: can't find referenced class javax.annotation.concurrent.GuardedBy
Warning:there were 3 unresolved references to classes or interfaces.
Warning:Exception while processing task java.io.IOException: Please correct the above warnings first.
Error:Execution failed for task ':app:transformClassesAndResourcesWithProguardForRelease'.

Job failed, see logs for details 

以下是我按照他们的建议用于 Retrofit 和 OKHTTP 的混淆器规则

# Platform calls Class.forName on types which do not exist on Android to determine platform.
-dontnote retrofit2.Platform
# Platform used when running on Java 8 VMs. Will not be used at runtime.
-dontwarn retrofit2.Platform$Java8
# Retain generic type information for use by reflection by converters and adapters.
-keepattributes Signature
# Retain declared checked exceptions for use by a Proxy instance.
-keepattributes Exceptions
-dontwarn org.xmlpull.v1.**
-dontwarn okhttp3.**
-keep class okhttp3.** { *; }
-dontwarn okio.**
-dontwarn javax.annotation.Nullable
-dontwarn javax.annotation.ParametersAreNonnullByDefault

我还需要补充什么? 任何帮助将不胜感激。

最佳答案

正如 JakeWharton 在 GitHub 上所说,我们只需要添加以下行:

-dontwarn javax.annotation.**

不需要这个

-keep class okhttp3.** { *; }

关于android - 生成签名 APK 时改造 2.3.0 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43999192/

相关文章:

java - Android: ContactsContract查询,需要更高级的选择字符串

android - 未知类 ILicensingService 混淆 Android 项目时的注意事项

android - 使用协程测试改造

Android App 在 Debug模式下工作,但在 Release模式下不工作

java - 关于oneToMany和ForeignKey的DBFlow问题

android - Proguard 与应用内购买 "Duplicate zip entry"错误

java - Retrofit2 : Error Handling

android - 如何在改造中使用 HashMap 发布数据?

java - Android 在发出多个 http 请求时增加堆 fragment 情况

java - 如何在 Android 版 Eclipse Juno 中安装 Proguard