I'm doing ProGuard in my app as:
shrinkResources true
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
and when I try to do an http call with Retrofit2 I get the exception:
java.lang.IllegalArgumentException: Missing either @GET URL or @Url parameter.
The Service
is:
interface ContentService {
@GET
fun getCMSCon(@Url url: String): Single<CMSCon>
}
It doesn't happen when minifyEnabled false
and shrinkResources false
I took a research on Internet and I ended up modifying the proguard-rules.pro
as:
# Retrofit
-dontwarn retrofit2.**
-keep class retrofit2.** { *; }
-keepattributes Signature
-keepattributes Exceptions
-keepattributes *Annotation*
-keepattributes RuntimeVisibleAnnotations
-keepattributes RuntimeInvisibleAnnotations
-keepattributes RuntimeVisibleParameterAnnotations
-keepattributes RuntimeInvisibleParameterAnnotations
-keepattributes EnclosingMethod
-keepclasseswithmembers class * {
@retrofit2.* <methods>;
}
-keepclasseswithmembers interface * {
@retrofit2.* <methods>;
}
but nothing changed.
The @Url
is passed from res
and literal, to check that there's not a problem with the Flavors.
Solution would be applying @Keep
in any call described in any interface
as Service:
@Keep
@GET
fun getCMSConfig(@Url url: String): Single<CMSConfig>