简体   繁体   English

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

[英]Retrofit 2.3.0 Error while generating signed APK

I have updated Retrofit v 2.3.0 and okhttp 3.8.0 and okio 1.13.0 but now while I am trying to generate signed APK I am getting following error : 我已经更新了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 

Following are the proguard rules which I am using for Retrofit and OKHTTP as suggested by them 以下是我用于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

What else I need to add ? 我还需要添加什么? Any help would be much appreciated. 任何帮助将非常感激。

As stated by JakeWharton on GitHub we just need to add following line : 正如JakeWharton在GitHub上所说,我们只需添加以下行:

-dontwarn javax.annotation.**

And no need of this 而且不需要这个

-keep class okhttp3.** { *; }

Be sure to include the following lines in Proguard in order to use Retrofit 2 请务必在Proguard中包含以下行以使用Retrofit 2

-dontwarn retrofit2.**
-keep class retrofit2.** { *; }
-keepattributes Signature
-keepattributes Exceptions

-keepclasseswithmembers class * {
    @retrofit2.http.* <methods>;
}
-keepclasseswithmembers interface * {
    @retrofit2.http.* <methods>;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM