Upgrade 2.3.0 Error creating signed APK

I updated Retrofit v 2.3.0 and okhttp 3.8.0 and okio 1.13.0, but now when I try to generate a signed APK, I get the following error:

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 

Below are the proguard rules that I use for Retrofit and OKHTTP, as suggested by them

# 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 do I need to add? Any help would be greatly appreciated.

+4
source share
2 answers

As pointed out by JakeWharton on GitHub, we just need to add the following line:

-dontwarn javax.annotation.**

And do not need this

-keep class okhttp3.** { *; }
+8
source

Be sure to include the following lines in Proguard to use Retrofit 2

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

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

Source: https://habr.com/ru/post/1677243/


All Articles