当我安装已发布的 apk 时遇到以下错误,它适用于调试 apk。 调用 get api 应用程序时崩溃。
Gradle 版本
id 'com.android.application' version '8.2.0' apply false
id 'com.android.library' version '8.2.0' apply false
改装版本
implementation 'com.squareup.retrofit2:retrofit:2.9.0'
implementation 'com.squareup.retrofit2:converter-gson:2.9.0'
implementation 'com.squareup.okhttp3:logging-interceptor:5.0.0-alpha.10'
错误
Exception java.lang.IllegalArgumentException:
at retrofit2.Utils.methodError (Utils.java:1)
at retrofit2.HttpServiceMethod.createCallAdapter (HttpServiceMethod.java:56)
at retrofit2.HttpServiceMethod.parseAnnotations (HttpServiceMethod.java:56)
at retrofit2.ServiceMethod.parseAnnotations (ServiceMethod.java:56)
at retrofit2.Retrofit.loadServiceMethod (Retrofit.java:1)
at retrofit2.Retrofit$1.invoke (Retrofit.java:40)
at java.lang.reflect.Proxy.invoke (Proxy.java:1006)
at $Proxy2.b
at com.ezytracking.datasources.repo.LoginDataRepository.checkIsValidUser (LoginDataRepository.java:196)
at com.ezytracking.ui.activities.LoginActivity$1.onClick (LoginActivity.java:196)
at android.view.View.performClick (View.java:7792)
at android.widget.TextView.performClick (TextView.java:16112)
at android.view.View.performClickInternal (View.java:7769)
at android.view.View.access$3800 (View.java:910)
at android.view.View$PerformClick.run (View.java:30218)
at android.os.Handler.handleCallback (Handler.java:938)
at android.os.Handler.dispatchMessage (Handler.java:99)
at android.os.Looper.loopOnce (Looper.java:226)
at android.os.Looper.loop (Looper.java:313)
at android.app.ActivityThread.main (ActivityThread.java:8669)
at java.lang.reflect.Method.invoke
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:571)
at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1135)
Caused by java.lang.IllegalArgumentException: Call return type must be parameterized as Call<Foo> or Call<? extends Foo>
at retrofit2.DefaultCallAdapterFactory.get (DefaultCallAdapterFactory.java:45)
at retrofit2.Retrofit.nextCallAdapter (Retrofit.java:33)
at retrofit2.Retrofit.callAdapter (Retrofit.java:33)
at retrofit2.HttpServiceMethod.createCallAdapter (HttpServiceMethod.java:45)
at retrofit2.HttpServiceMethod.parseAnnotations (HttpServiceMethod.java:45)
at retrofit2.ServiceMethod.parseAnnotations (ServiceMethod.java:45)
从你的描述来看,这看起来像是发布版本中的 Proguard 原因。 确保您已通过此链接关注有关 Proguard 的改造文档: