Retrofit2 - 缺少@GET URL 或@Url 参数 - Proguard
Retrofit2 - Missing either @GET URL or @Url parameter - Proguard
我在我的应用程序中使用 ProGuard 作为:
shrinkResources true
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
当我尝试使用 Retrofit2 进行 http 调用时,出现异常:
java.lang.IllegalArgumentException: Missing either @GET URL or @Url parameter.
Service
是:
interface ContentService {
@GET
fun getCMSCon(@Url url: String): Single<CMSCon>
}
当minifyEnabled false
和shrinkResources false
时不会发生
我在互联网上进行了研究,最后将 proguard-rules.pro
修改为:
# 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>;
}
但没有任何改变。
@Url
是从 res
和文字传递过来的,以检查 Flavors 是否存在问题。
解决方案将在任何 interface
描述的任何调用中应用 @Keep
作为服务:
@Keep
@GET
fun getCMSConfig(@Url url: String): Single<CMSConfig>
我在我的应用程序中使用 ProGuard 作为:
shrinkResources true
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
当我尝试使用 Retrofit2 进行 http 调用时,出现异常:
java.lang.IllegalArgumentException: Missing either @GET URL or @Url parameter.
Service
是:
interface ContentService {
@GET
fun getCMSCon(@Url url: String): Single<CMSCon>
}
当minifyEnabled false
和shrinkResources false
我在互联网上进行了研究,最后将 proguard-rules.pro
修改为:
# 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>;
}
但没有任何改变。
@Url
是从 res
和文字传递过来的,以检查 Flavors 是否存在问题。
解决方案将在任何 interface
描述的任何调用中应用 @Keep
作为服务:
@Keep
@GET
fun getCMSConfig(@Url url: String): Single<CMSConfig>