There is no such method error when using robospice-retrofit and getstream.io

In our project, we use 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 Thus, gradle is selected here, 2.2.0 and the error appears below, since this 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 version 2.2.0 from the thread library. This gives an error below since this method is not available in version 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 I do now ?, Thanks for the support

+6
source share

Source: https://habr.com/ru/post/1017215/


All Articles