Sanyasirao Mopada Sanyasirao Mopada - 1 year ago 56
Android Question

No such method error while using robospice-retrofit and getstream.io

In our project we are using
com.octo.android.robospice:robospice-retrofit:1.4.14 , Which require okhttp: 1.6.0

And getstream java client

io.getstream.client:stream-repo-okhttp:1.2.2', Which require okhttp:2.2.0
So here gradle is picking up, 2.2.0 and Giving below error as that method is not available in 2.2.0

java.lang.NoSuchMethodError: No virtual method open(Ljava/net/URL;)Ljava/net/HttpURLConnection; in class Lcom/squareup/okhttp/OkHttpClient; or its super classes (declaration of 'com.squareup.okhttp.OkHttpClient' appears in /data/app/com.#########.apk)
at com.squareup.okhttp.OkUrlFactory.open(OkUrlFactory.java:44)
at retrofit.client.OkClient.openConnection(OkClient.java:45)
at retrofit.client.UrlConnectionClient.execute(UrlConnectionClient.java:36)
at retrofit.RestAdapter$RestHandler.invokeRequest(RestAdapter.java:321)
at retrofit.RestAdapter$RestHandler.access$100(RestAdapter.java:220)
at retrofit.RestAdapter$RestHandler$2.obtainResponse(RestAdapter.java:278)
at retrofit.CallbackRunnable.run(CallbackRunnable.java:42)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at retrofit.Platform$Android$2$1.run(Platform.java:142)
at java.lang.Thread.run(Thread.java:811)


If I exclude 2.2.0 version from stream library.It's giving below error as that method is not available in 1.6.0

java.lang.NoSuchMethodError: No virtual method setWriteTimeout(JLjava/util/concurrent/TimeUnit;)V in class Lcom/squareup/okhttp/OkHttpClient; or its super classes (declaration of 'com.squareup.okhttp.OkHttpClient' appears in /data/app/co.ibhubs.startup.alpha-1/base.apk)
at io.getstream.client.okhttp.repo.StreamRepoFactoryImpl.initClient(StreamRepoFactoryImpl.java:45)
at io.getstream.client.okhttp.repo.StreamRepoFactoryImpl.newInstance(StreamRepoFactoryImpl.java:38)
at io.getstream.client.okhttp.StreamClientImpl.<init>(StreamClientImpl.java:29)
at com.ibtspl.startup.utils.Application.onCreate(Application.java:47)
at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1014)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4726)
at android.app.ActivityThread.access$1600(ActivityThread.java:153)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1412)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5441)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:738)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:628)


I need to use both libraries.What should do now?, Thanks for your support

Answer Source

We resolved it by using unofficial robospice with retrofit2 support dependency from @mykolaj . You can find the solution at below link

https://github.com/stephanenicolas/robospice/issues/469

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download