React-native: AndroidRuntime: FATAL EXCEPTION: OkHttp Dispatcher

Created on 18 Nov 2019  ·  8Comments  ·  Source: facebook/react-native

E AndroidRuntime: java.lang.NoSuchMethodError: No virtual method toString(Z)Ljava/lang/String; in class Lokhttp3/Cookie; or its super classes (declaration of 'okhttp3.Cookie' appears in /data/app/com.piglet-VoaKTU4zctXOlMHherGcyg==/base.apk!classes2.dex)
E AndroidRuntime: at okhttp3.JavaNetCookieJar.saveFromResponse(JavaNetCookieJar.java:45)
E AndroidRuntime: at com.facebook.react.modules.network.ReactCookieJarContainer.saveFromResponse(ReactCookieJarContainer.java:36)
E AndroidRuntime: at okhttp3.internal.http.HttpHeaders.receiveHeaders(HttpHeaders.kt:207)
E AndroidRuntime: at okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.kt:86)
E AndroidRuntime: at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:112)
E AndroidRuntime: at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.kt:71)
E AndroidRuntime: at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:112)
E AndroidRuntime: at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:87)
E AndroidRuntime: at okhttp3.RealCall.getResponseWithInterceptorChain(RealCall.kt:184)
E AndroidRuntime: at okhttp3.RealCall$AsyncCall.run(RealCall.kt:136)
E AndroidRuntime: at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)
E AndroidRuntime: at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
E AndroidRuntime: at java.lang.Thread.run(Thread.java:764)

React Native version:
System:
OS: macOS Mojave 10.14.6
CPU: (6) x64 Intel(R) Core(TM) i5-8500 CPU @ 3.00GHz
Memory: 22.18 MB / 8.00 GB
Shell: 3.2.57 - /bin/bash
Binaries:
Node: 12.10.0 - /usr/local/bin/node
Yarn: 1.17.3 - /usr/local/bin/yarn
npm: 6.10.3 - /usr/local/bin/npm
Watchman: 4.9.0 - /usr/local/bin/watchman
SDKs:
iOS SDK:
Platforms: iOS 13.2, DriverKit 19.0, macOS 10.15, tvOS 13.2, watchOS 6.1
Android SDK:
API Levels: 21, 23, 24, 25, 26, 27, 28, 29
Build Tools: 25.0.2, 25.0.3, 28.0.3, 29.0.0, 29.0.2
System Images: android-21 | Android TV ARM EABI v7a, android-21 | Android TV Intel x86 Atom, android-21 | ARM EABI v7a, android-21 | Intel x86 Atom, android-21 | Intel x86 Atom_64, android-21 | Google APIs ARM EABI v7a, android-21 | Google APIs Intel x86 Atom, android-21 | Google APIs Intel x86 Atom_64, android-23 | Android TV ARM EABI v7a, android-23 | Android TV Intel x86 Atom, android-23 | Android Wear ARM EABI v7a, android-23 | Android Wear Intel x86 Atom, android-23 | ARM EABI v7a, android-23 | Intel x86 Atom, android-23 | Intel x86 Atom_64, android-23 | Google APIs ARM EABI v7a, android-23 | Google APIs Intel x86 Atom, android-23 | Google APIs Intel x86 Atom_64, android-24 | Android TV Intel x86 Atom, android-24 | ARM 64 v8a, android-24 | ARM EABI v7a, android-24 | Intel x86 Atom, android-24 | Intel x86 Atom_64, android-24 | Google APIs ARM 64 v8a, android-24 | Google APIs ARM EABI v7a, android-24 | Google APIs Intel x86 Atom, android-24 | Google APIs Intel x86 Atom_64, android-24 | Google Play Intel x86 Atom, android-26 | Android TV Intel x86 Atom, android-26 | China version of Android Wear Intel x86 Atom, android-26 | Android Wear Intel x86 Atom, android-26 | Intel x86 Atom, android-26 | Intel x86 Atom_64, android-26 | Google APIs Intel x86 Atom, android-26 | Google APIs Intel x86 Atom_64, android-26 | Google Play Intel x86 Atom, android-28 | Google Play Intel x86 Atom, android-29 | Google APIs Intel x86 Atom, android-Q | Android TV Intel x86 Atom
IDEs:
Android Studio: 3.5 AI-191.8026.42.35.5791312
Xcode: 11.2/11B52 - /usr/bin/xcodebuild
npmPackages:
react: 16.9.0 => 16.9.0
react-native: 0.61.1 => 0.61.1
npmGlobalPackages:
react-native-asset: 2.0.0
react-native-cli: 2.0.1
react-native-update-cli: 0.1.0

Bug Android 🌐Networking

Most helpful comment

apologies for the late response -
towards the end of the file - there is an existing section for dependencies

so including a implementation or compile would look like

dependencies {
     compile "com.squareup.okhttp3:okhttp:4.2.1"
     compile "com.squareup.okhttp3:logging-interceptor:4.2.1"
     compile "com.squareup.okhttp3:okhttp-urlconnection:4.2.1"
}

All 8 comments

same runtime error here - build is fine

My android technical knowledge is still a bit limited - but from what i can research
https://github.com/square/okhttp/issues/5425 -> leaves me to believe it is caused by different version numbers in the okhttp dependency

my fix to get the build to stop crashing during runtime was to include these in my android/app/build.gradle

    compile "com.squareup.okhttp3:okhttp:4.2.1"
    compile "com.squareup.okhttp3:logging-interceptor:4.2.1"
    compile "com.squareup.okhttp3:okhttp-urlconnection:4.2.1"

i assume the correct fix is to find which added import from your project is causing the version discrepancy, but this overriding works for me temporarily

同样的运行时错误-构建很好

我的Android技术知识仍然有限-但据我
所知,square / okhttp#5425- >让我相信这是由okhttp依赖项中的不同版本号引起的

我要让构建在运行时停止崩溃的解决方法是将这些包含在我的android / app / build.gradle中

    compile "com.squareup.okhttp3:okhttp:4.2.1"
    compile "com.squareup.okhttp3:logging-interceptor:4.2.1"
    compile "com.squareup.okhttp3:okhttp-urlconnection:4.2.1"

我认为正确的解决方法是找到从您的项目中添加的哪些导入导致版本差异,但是此替代对我暂时有效

thanks!

have the same issue as well. @JeffKGabriel , could you create screenshot how I can paste your 'magic strings' into android/app/build.gradle

apologies for the late response -
towards the end of the file - there is an existing section for dependencies

so including a implementation or compile would look like

dependencies {
     compile "com.squareup.okhttp3:okhttp:4.2.1"
     compile "com.squareup.okhttp3:logging-interceptor:4.2.1"
     compile "com.squareup.okhttp3:okhttp-urlconnection:4.2.1"
}

Thanks @JeffKGabriel It's solves the problem.

apologies for the late response -
towards the end of the file - there is an existing section for dependencies

so including a implementation or compile would look like

dependencies {
     compile "com.squareup.okhttp3:okhttp:4.2.1"
     compile "com.squareup.okhttp3:logging-interceptor:4.2.1"
     compile "com.squareup.okhttp3:okhttp-urlconnection:4.2.1"
}

Thanks @JeffKGabriel ,

Few lines about my findings,

Actually, my app got crashed in android device with API response as 'SKIPPED' in reactotron log,
I tried to track with android studio and found FATAL EXCEPTION: OkHttp Dispatcher and issue solved with these above lines.

apologies for the late response -
towards the end of the file - there is an existing section for dependencies

so including a implementation or compile would look like

dependencies {
     compile "com.squareup.okhttp3:okhttp:4.2.1"
     compile "com.squareup.okhttp3:logging-interceptor:4.2.1"
     compile "com.squareup.okhttp3:okhttp-urlconnection:4.2.1"
}

Thanks!
I was all day trying to solve this problem, you saved me.

I have been getting this error, which I fixed using @JeffKGabriel 's comment, but on publishing the app to the Play Store I get a TrustManager vulnerability warning from Google Play.

Any clues, anyone?

Edit: The issue was an insecure implementation of TrustManager in a Native Android SDK I had integrated.

Was this page helpful?
0 / 5 - 0 ratings