生成签名APK时出现改造2.3.0错误

时间:2017-05-16 10:40:29

标签: 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的proguard规则,如他们所建议的那样

# 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

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

2 个答案:

答案 0 :(得分:11)

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

-dontwarn javax.annotation.**

不需要这个

-keep class okhttp3.** { *; }

答案 1 :(得分:3)

请务必在Proguard中包含以下行以使用Retrofit 2

<key>LSApplicationQueriesSchemes</key>
<array>
   <string>ebizupv3doc</string>
</array>