react-nativeokhttpreact-android

Okhttp error during React Navtive GET request


Receiving this error during an otherwise valid GET request in a react-native project.

2020-08-11 12:12:54.163 7301-7498/com.cigna.mobile.mycigna.debug E/AndroidRuntime: FATAL EXCEPTION: OkHttp Dispatcher
    Process: com.cigna.mobile.mycigna.debug, PID: 7301
    java.lang.NoSuchMethodError: No static method delimiterOffset(Ljava/lang/String;IILjava/lang/String;)I in class Lokhttp3/internal/Util; or its super classes (declaration of 'okhttp3.internal.Util' appears in /data/app/~~-wSG5UWGWR49_zqj0uGdfw==/com.cigna.mobile.mycigna.debug-O6Kl4LYWC-jBUFRzAxGZug==/base.apk!classes6.dex)
        at okhttp3.JavaNetCookieJar.decodeHeaderAsJavaNetCookies(JavaNetCookieJar.java:91)
        at okhttp3.JavaNetCookieJar.loadForRequest(JavaNetCookieJar.java:74)
        at com.facebook.react.modules.network.ReactCookieJarContainer.loadForRequest(ReactCookieJarContainer.java:44)
        at okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.kt:75)
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:112)
        at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.kt:71)
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:112)
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:87)
        at okhttp3.RealCall.getResponseWithInterceptorChain(RealCall.kt:184)
        at okhttp3.RealCall$AsyncCall.run(RealCall.kt:136)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
        at java.lang.Thread.run(Thread.java:923)
2020-08-11 12:12:54.552 631-716/system_process E/InputDispatcher: channel '94b38db com.cigna.mobile.mycigna.debug/com.cigna.mycigna.ui.dashboard.HomeActivity (server)' ~ Channel is unrecoverably broken and will be disposed!

All other api requests on my application work without problem. As well, the request mentioned works seemlessly on iOS.


Solution

  • You've got two libraries: okhttp and okhttp-urlconnection. They must be on the same exact version or you may receive this error.