更新gradle后,改造2出现错误:java.lang.NoSuchMethodError:com.google.gson.Gson.newJsonReader

时间:2016-12-15 13:39:34

标签: android retrofit2 rx-android

我的问题出现在我使用gradle 2.2版更新Android工作室到最新版本。*。我正在使用匕首2 rxjava改装并碰巧遇到这个问题:

E/AndroidRuntime: FATAL EXCEPTION: RxCachedThreadScheduler-1
              Process: com.appsmedia.blaan2, PID: 19224
              java.lang.IllegalStateException: Fatal Exception thrown on Scheduler.Worker thread.
                  at rx.internal.schedulers.ScheduledAction.run(ScheduledAction.java:62)
                  at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:422)
                  at java.util.concurrent.FutureTask.run(FutureTask.java:237)
                  at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:152)
                  at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:265)
                  at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
                  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
                  at java.lang.Thread.run(Thread.java:841)
               Caused by: java.lang.NoSuchMethodError: com.google.gson.Gson.newJsonReader
                  at retrofit2.converter.gson.GsonResponseBodyConverter.convert(GsonResponseBodyConverter.java:35)
                  at retrofit2.converter.gson.GsonResponseBodyConverter.convert(GsonResponseBodyConverter.java:25)
                  at retrofit2.ServiceMethod.toResponse(ServiceMethod.java:116)
                  at retrofit2.OkHttpCall.parseResponse(OkHttpCall.java:211)
                  at retrofit2.OkHttpCall.execute(OkHttpCall.java:174)
                  at retrofit2.adapter.rxjava.RxJavaCallAdapterFactory$RequestArbiter.request(RxJavaCallAdapterFactory.java:171)
                  at rx.internal.operators.OperatorSubscribeOn$1$1$1.request(OperatorSubscribeOn.java:80)
                  at rx.Subscriber.setProducer(Subscriber.java:211)
                  at rx.internal.operators.OperatorSubscribeOn$1$1.setProducer(OperatorSubscribeOn.java:76)
                  at rx.Subscriber.setProducer(Subscriber.java:205)
                  at retrofit2.adapter.rxjava.RxJavaCallAdapterFactory$CallOnSubscribe.call(RxJavaCallAdapterFactory.java:152)
                  at retrofit2.adapter.rxjava.RxJavaCallAdapterFactory$CallOnSubscribe.call(RxJavaCallAdapterFactory.java:138)
                  at rx.Observable$2.call(Observable.java:233)
                  at rx.Observable$2.call(Observable.java:225)
                  at rx.Observable.unsafeSubscribe(Observable.java:8741)
                  at rx.internal.operators.OperatorSubscribeOn$1.call(OperatorSubscribeOn.java:94)
                  at rx.internal.schedulers.ScheduledAction.run(ScheduledAction.java:55)
                  at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:422) 
                  at java.util.concurrent.FutureTask.run(FutureTask.java:237) 
                  at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:152) 
                  at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:265) 
                  at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112) 
                  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587) 
                  at java.lang.Thread.run(Thread.java:841) 

1 个答案:

答案 0 :(得分:0)

(代表OP发布)

将改装版改为最新版本解决了我的问题。