NoSuchMethodError Lcom / google / gson / Gson;根据改造响应

时间:2018-07-27 12:14:35

标签: android gson retrofit2 nosuchmethoderror

因此,我的应用发布了将近一年,却没有看到这个问题,现在它出现了。
即使是现在,我的手机上的调试版本也没有这个问题。从Android Studio打开的任何模拟器都没有任何问题。但是,在收到Retrofit响应后,几乎所有来自Google开发者控制台发布前报告的仿真器都会由于此NoSuchMethodError崩溃。

FATAL EXCEPTION: ControllerMessenger
Process: xxxxxxx, PID: 25090
java.lang.NoSuchMethodError: No direct method <init>(Lcom/google/gson/Gson;)V in class Lcom/google/gson/Gson$1; or its super classes (declaration of 'com.google.gson.Gson$1' appears in /data/app/com.google.android.apps.mtaas.crawler-1/base.apk)
at com.google.gson.Gson.doubleAdapter(Gson.java:278)
at com.google.gson.Gson.<init>(Gson.java:217)
at com.google.gson.Gson.<init>(Gson.java:174)
at retrofit2.converter.gson.GsonConverterFactory.create(GsonConverterFactory.java:42)
at xxxxxxx.MtbActivity.loadJSON(MtbActivity.java:149)
at xxxxxxx.MtbActivity.onCreate(MtbActivity.java:135)
at android.app.Activity.performCreate(Activity.java:6013)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1108)
at androidx.test.runner.MonitoringInstrumentation.callActivityOnCreate(MonitoringInstrumentation.java:215)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2359)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2466)
at android.app.ActivityThread.access$1200(ActivityThread.java:152)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1341)
at android.os.Handler.dispatchMessage(Handler.java:102)
at androidx.test.espresso.base.Interrogator.a(Interrogator.java:19)
at androidx.test.espresso.base.UiControllerImpl.a(UiControllerImpl.java:142)
at androidx.test.espresso.base.UiControllerImpl.a(UiControllerImpl.java:134)
at androidx.test.espresso.base.UiControllerImpl.a(UiControllerImpl.java:114)
at androidx.test.espresso.action.Tap$1.b(Tap.java:6)
at androidx.test.espresso.action.GeneralClickAction.perform(GeneralClickAction.java:22)
at androidx.test.espresso.ViewInteraction$SingleExecutionViewAction.perform(ViewInteraction.java:9)
at androidx.test.espresso.ViewInteraction.a(ViewInteraction.java:78)
at androidx.test.espresso.ViewInteraction.a(ViewInteraction.java:94)
at androidx.test.espresso.ViewInteraction$1.call(ViewInteraction.java:3)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5538)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:960)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755)

我尝试过的事情:

  1. 将Retrofit和Gson依赖项更新到最新版本。
  2. 使缓存无效并重新启动
implementation 'com.squareup.retrofit2:retrofit:2.4.0'
implementation 'com.squareup.retrofit2:converter-gson:2.4.0'

1 个答案:

答案 0 :(得分:0)

感谢彼得here

总结:

现有的搜寻器为FUBAR。作为解决方法,您可以选择退出新发布的爬虫,以返回到旧版本。

以下是退出的方法:

登录到您的Play控制台。 选择一个应用。 选择发布管理>预发布报告>设置。在“发布前报告版本”部分中,将“退出”开关移至右侧,直到其变为蓝色。 此后,启动报告将再次正确显示。