Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
quachdev opened this issue Jun 11, 2021 · 9 comments
Closed
Assignees

Comments

@quachdev
Copy link

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.

@JeroenMols
Copy link
Collaborator

What version of Okhttp are you using?

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

@quachdev
Copy link
Author

quachdev commented Jun 18, 2021

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

@JeroenMols
Copy link
Collaborator

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!

@mptmadhushan
Copy link

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

@quachdev
Copy link
Author

@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
Copy link
Author

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'
}

@amritanshMedwhiz
Copy link

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

@Kerumen
Copy link

Kerumen commented Feb 28, 2022

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.

@dtroupe-plaid
Copy link
Collaborator

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants