我在我的项目中使用了以下的库 -
compile 'com.squareup.retrofit:retrofit:1.9.0'
但是当我使用Proguard时,我的应用程序崩溃并出现以下错误
Fatal Exception: java.lang.IllegalArgumentException: d.a: Last parameter must be of type Callback<X> or Callback<? super X>.
at retrofit.RestMethodInfo.methodError(Unknown Source)
at retrofit.RestMethodInfo.parseResponseType(Unknown Source)
at retrofit.RestMethodInfo.(Unknown Source)
at retrofit.RestAdapter.create(Unknown Source)
at retrofit.RestAdapter$RestHandler.invoke(Unknown Source)
at java.lang.reflect.Proxy.invoke(Proxy.java:393)
at $Proxy2.a(Unknown Source)
at in.wishup.assistant.activities.SplashActivity.fetchOneTouchDetails(Unknown Source)
at in.wishup.assistant.activities.SplashActivity$1.done(Unknown Source)
at in.wishup.assistant.activities.SplashActivity$1.done(Unknown Source)
at com.parse.ParseTaskUtils$2$1.run(Unknown Source)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
我认为Retrofit的Asynchronus调用不适用于Proguard。有人遇到类似的问题吗?我尝试了许多链接,但没有任何效果。
##proguard-rules.pro##
-keep class com.google.android.gms.* { *; } <br> -keep class * extends android.app.Activity <br> -keepclassmembers class ** { <br>
@com.squareup.otto.Subscribe public *;<br>
@com.squareup.otto.Produce public *;<br> }<br> -keepnames class com.levelup.http.okhttp.** { *; }<br> -keepnames interface com.levelup.http.okhttp.** { *; }<br> -keepnames class com.squareup.okhttp.** { *; }<br> -keepnames interface com.squareup.okhttp.** { *; }<br>
-dontwarn com.squareup.okhttp.internal.http.*<br>
-dontwarn org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement<br>
-keepattributes Signature<br>
-keepattributes *Annotation*<br>
-dontwarn rx.**<br>
-keep class com.google.gson.** { *; }<br>
-keep class com.google.inject.* { *; }<br>
-keep class org.apache.http.* { *; }<br>
-keep class org.apache.james.mime4j.* { *; }<br>
-keep class javax.inject.* { *; }<br>
-keep class retrofit.* { *; }<br>
-keep class sun.misc.Unsafe { *; }<br>
-keep class in.wishup.assistant.testobfuscation.** { *; }<br> -keep class retrofit.** { *; }<br> -keepclasseswithmembers class * {<br>
@retrofit.http.* <methods>;<br> }<br>
-keep class com.parse.* { *; }<br> -dontwarn com.parse.*<br>
-dontwarn retrofit.appengine.**<br>
-keep class com.package.name.models.** { *; }<br> -keepclassmembers class com.package.name.models.** { *; } <br>
答案 0 :(得分:1)
如果在休息服务界面中使用Callback方法 参数。
-keepattributes Exceptions