react-native-plaid-link-sdk icon indicating copy to clipboard operation
react-native-plaid-link-sdk copied to clipboard

Upgrade 0.63.4 to 0.64.2 - TypeError: Network request failed - Android

Open quachdev opened this issue 3 years ago • 8 comments

Description

When making any network request using fetch on Android I am immediately receiving TypeError: Network request failed and the app crashes.

This works fine on iOS and seems to be Android specific.

Downgrading to 0.63.4 works fine.

From flipper logs:

FATAL EXCEPTION: OkHttp Dispatcher

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/~~MpYZ_TQ66BEt9s5EWN7J8w==/com.myapp-7OHSdQhHSKPSzxLGYKEDgg==/base.apk!classes4.dex)

FATAL EXCEPTION: OkHttp Dispatcher
Process: com.myapp, PID: 8581
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/~~MpYZ_TQ66BEt9s5EWN7J8w==/com.myapp-7OHSdQhHSKPSzxLGYKEDgg==/base.apk!classes4.dex)
	at okhttp3.JavaNetCookieJar.saveFromResponse(JavaNetCookieJar.java:45)
	at com.facebook.react.modules.network.ReactCookieJarContainer.saveFromResponse(ReactCookieJarContainer.java:37)
	at okhttp3.internal.http.HttpHeaders.receiveHeaders(HttpHeaders.kt:207)
	at okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.kt:85)
	at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
	at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.kt:76)
	at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
	at okhttp3.internal.connection.RealCall.getResponseWithInterceptorChain$okhttp(RealCall.kt:201)
	at okhttp3.internal.connection.RealCall$AsyncCall.run(RealCall.kt:517)
	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)

React Native version:

System: OS: macOS 11.4 CPU: (12) x64 Intel(R) Core(TM) i7-8850H CPU @ 2.60GHz Memory: 67.71 MB / 16.00 GB Shell: 5.8 - /bin/zsh Binaries: Node: 15.6.0 - /usr/local/bin/node Yarn: 1.22.10 - /usr/local/bin/yarn npm: 7.4.0 - /usr/local/bin/npm Watchman: 4.9.0 - /usr/local/bin/watchman Managers: CocoaPods: 1.10.1 - /usr/local/bin/pod SDKs: iOS SDK: Platforms: iOS 14.5, DriverKit 20.4, macOS 11.3, tvOS 14.5, watchOS 7.4 Android SDK: API Levels: 28, 29, 30 Build Tools: 28.0.3, 29.0.2, 30.0.3, 31.0.0 System Images: android-28 | Google APIs Intel x86 Atom, android-29 | Intel x86 Atom_64, android-29 | Google APIs Intel x86 Atom, android-29 | Google APIs Intel x86 Atom_64, android-30 | Google APIs Intel x86 Atom, android-30 | Google Play Intel x86 Atom Android NDK: 22.1.7171670 IDEs: Android Studio: 4.2 AI-202.7660.26.42.7351085 Xcode: 12.5/12E262 - /usr/bin/xcodebuild Languages: Java: 1.8.0_275 - /usr/bin/javac npmPackages: @react-native-community/cli: Not Found react: 17.0.1 => 17.0.1 react-native: 0.64.2 => 0.64.2 react-native-macos: Not Found npmGlobalPackages: react-native: Not Found

react-native-plaid-link-sdk: 7.0.6

Steps To Reproduce

Provide a detailed list of steps that reproduce the issue.

  1. Create a new project
  2. yarn add react-native-plaid-link-sdk
  3. Follow the RN Plaid Android Setup docs
  4. Make a network request using fetch
  5. App should fail with TypeError: Network request failed

Expected Results

App should be able to make the network request and not crash from the result.

I originally posted this on the main react-native repo but, back tracing my steps I am very certain it's related to this package.

quachdev avatar Jun 11 '21 00:06 quachdev

What version of Okhttp are you using?

You can get all your project dependencies by running ./gradlew :app:dependencies from the android folder.

JeroenMols avatar Jun 17 '21 13:06 JeroenMols

From the screenshot it looks like 3.12.12. I am unsure however, what it means by (Test) after the dependency. The one on the react-native-plaid-link-sdk dependency says (Compile) and is a higher version in alpha stage it seems?

Could this be the cause?

Screen Shot 2021-06-18 at 12 40 15 AM

Screen Shot 2021-06-18 at 12 41 35 AM

quachdev avatar Jun 18 '21 04:06 quachdev

From the screenshots above, it seems like you are using okhttp:5.0.0-alpha.2, though from the error my hunch would say that you are using an older version. 🤔

Could you try forcing the okhttp dependency in you main build.gradle file?

    configurations.all {
        resolutionStrategy.force 'com.squareup.okhttp3:okhttp:4.9.1'
    }

If that works, please also try to force the version to 5.0.0-alpha.2 and to 3.14.9 to help pin down the problem.

Thanks for your support!

JeroenMols avatar Jun 21 '21 10:06 JeroenMols

I have the same issue is there any fixes..? I have tried days

mptmadhushan avatar Jun 30 '21 22:06 mptmadhushan

@JeroenMols I have added your suggestion into the build.gradle file. I am still experiencing the same problem. Could I be adding it in the wrong area? I added it at the bottom outside of allprojects { ... }

quachdev avatar Jul 29 '21 20:07 quachdev

This ended up working for us.

Turns out we were a few additional dependencies ended up conflicting with this package:

configurations.all {
    resolutionStrategy.force 'com.squareup.okhttp3:okhttp:4.9.1'
    resolutionStrategy.force 'com.squareup.okhttp3:okhttp-urlconnection:4.9.1'
    resolutionStrategy.force 'com.squareup.okio:okio:2.7.0'
}

quachdev avatar Aug 16 '21 18:08 quachdev

@quachdev i am facing the same issue, did you find any solution for this issue

amritanshMedwhiz avatar Sep 15 '21 07:09 amritanshMedwhiz

I also faced this issue and solved either using the configurations.all block as mentioned here or by adding the following snippet in the dependencies block.

implementation "com.squareup.okhttp3:okhttp-urlconnection:4.+"

It looks like com.plaid.link:sdk-core is using okhttp-urlconnection but is not declaring it in its dependencies. In my app, I do have okhttp3:okhttp v4 (and some v3) but I only have okhttp-urlconnection v3.

Kerumen avatar Feb 28 '22 13:02 Kerumen

Closing because Plaid Link React Native 7.x.x is no longer supported. If the issue persists in the latest SDK please open a new issue.

dtroupe-plaid avatar Jul 18 '23 17:07 dtroupe-plaid