gpt4 book ai didi

java - Proguard 处于 Activity 状态时无法创建调用适配器崩溃

转载 作者:搜寻专家 更新时间:2023-11-01 07:49:27 27 4
gpt4 key购买 nike

我想在我的项目中使用 ProGuard。我激活了选项 minifyEnabled。当我打开使用库 Retrofit2 的 Activity 时,应用程序崩溃并显示:

无法为接口(interface) retrofit2.Call 创建调用适配器

java.lang.RuntimeException: Unable to start activity ComponentInfo{com.gatafan.mydeen/com.gatafan.mydeen.ActivityPlaces}:
java.lang.IllegalArgumentException: Unable to create call adapter for interface retrofit2.Call
for method i.a
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2338)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2390)
at android.app.ActivityThread.access$800(ActivityThread.java:151)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1321)
at android.os.Handler.dispatchMessage(Handler.java:110)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:5292)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:824)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:640)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.IllegalArgumentException: Unable to create call adapter for interface retrofit2.Call
for method i.a
at retrofit2.ServiceMethod$Builder.a(Unknown Source)
at retrofit2.ServiceMethod$Builder.b(Unknown Source)
at retrofit2.ServiceMethod$Builder.a(Unknown Source)
at retrofit2.Retrofit.a(Unknown Source)
at retrofit2.Retrofit$1.invoke(Unknown Source)
at com.gatafan.mydeen.api.$Proxy1.a(Native Method)
at com.gatafan.mydeen.api.VenueManager.requestFoursquare(Unknown Source)
at com.gatafan.mydeen.ActivityPlaces.onCreate(Unknown Source)
at android.app.Activity.performCreate(Activity.java:5264)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1088)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2302)
... 11 more
Caused by: java.lang.IllegalArgumentException: Call return type must be parameterized as Call<Foo> or Call<? extends Foo>
at retrofit2.Utils.e(Unknown Source)
at retrofit2.ExecutorCallAdapterFactory.a(Unknown Source)
at retrofit2.Retrofit.a(Unknown Source)
at retrofit2.Retrofit.a(Unknown Source)
... 21 more

最佳答案

在 Retrofit 的 github 页面中有一节解释了使用混淆器时要做什么:

PROGUARD If you are using Proguard in your project add the following lines to your configuration:

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

先尝试这个配置,然后再继续修改混淆器

关于java - Proguard 处于 Activity 状态时无法创建调用适配器崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37213793/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com