-
Notifications
You must be signed in to change notification settings - Fork 24.8k
Description
Description
This issue is reproduceable and uses React Native 0.78.2.
We’re building a brownfield Android app using React Native (0.78.2) alongside native Android modules. Our app requires:
- React Native (0.78.2): Internally depends on OkHttp 4.9.2 for all Android networking.
- AWS Amplify Android SDK (2.27.1): Requires OkHttp 5.0.0-alpha.11 (or higher).
Problem:
When making API calls from React Native screens, the Android native layer’s OkHttp version is used. This leads to a dependency conflict (detailed error log mentioned at the bottom):
- OkHttp 4.9.2 (required by React Native) and OkHttp 5.x (required by AWS Amplify 2.27.1) are incompatible.
Forcing the build to use one version breaks the other:
- Forcing OkHttp 4.9.2: Breaks AWS Amplify 2.27.1 (missing APIs, build errors).
- Forcing OkHttp 5.x: Breaks React Native networking (incompatible APIs, runtime errors).
Root Cause:
Both React Native and AWS Amplify require different, incompatible OkHttp versions, but only one version can be present in the final APK. This makes it impossible to use both stacks together without conflict.
Impact:
- Cannot use both React Native 0.78.2 and AWS Amplify Android 2.27.1 in the same app.
- API calls from React Native screens fail due to OkHttp version mismatches.
- Gradle dependency resolution fails, or runtime crashes occur.
Ask:
Is there any plan or technical possibility for React Native to upgrade OkHttp from 4.9.2 to 5.0.0+ in the Android Gradle build?
Log:
FATAL EXCEPTION: OkHttp Dispatcher (Ask Gemini) Process: com.ExampleApp.mobile.dev, PID: 30551 java.lang.NoClassDefFoundError: Failed resolution of: Lokhttp3/internal/Util; at okhttp3.JavaNetCookieJar.decodeHeaderAsJavaNetCookies(JavaNetCookieJar.kt:81) at okhttp3.JavaNetCookieJar.loadForRequest(JavaNetCookieJar.kt:59) at com.facebook.react.modules.network.ReactCookieJarContainer.loadForRequest(ReactCookieJarContainer.kt:37) at okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.kt:73) at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:126) at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.kt:72) at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:126) at okhttp3.internal.connection.RealCall.getResponseWithInterceptorChain$okhttp(RealCall.kt:203) at okhttp3.internal.connection.RealCall$AsyncCall.run(RealCall.kt:527) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1156) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:651) at java.lang.Thread.run(Thread.java:1119) Caused by: java.lang.ClassNotFoundException: Didn't find class "okhttp3.internal.Util" on path: DexPathList[[zip file "/data/app/~~VS4y1xXhJcA54X33Jpvdlg==/com.ExampleApp.mobile.dev-VsoAWRXrqWSlRrDRJ743IQ==/base.apk"],nativeLibraryDirectories=[/data/app/~~VS4y1xXhJcA54X33Jpvdlg==/com.ExampleApp.mobile.dev-VsoAWRXrqWSlRrDRJ743IQ==/lib/arm64, /data/app/~~VS4y1xXhJcA54X33Jpvdlg==/com.ExampleApp.mobile.dev-VsoAWRXrqWSlRrDRJ743IQ==/base.apk!/lib/arm64-v8a, /system/lib64, /system_ext/lib64]] at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:259) at java.lang.ClassLoader.loadClass(ClassLoader.java:637) at java.lang.ClassLoader.loadClass(ClassLoader.java:573)
Steps to reproduce
- Install react native template for brownfield app from the community repo : https://github.com/react-native-community/template/tree/0.78-stable/template
- For /android/gradle/libs.versions.toml I have this configured for my existing android app:
awsAppSync = "3.4.2"
awsAppSyncRuntime = "3.4.2"
awsSdkClient = "2.78.0"
awsAmplifyCognito = "2.27.1"
awsAmplify = "2.27.1"
amplifyAwsApi = "2.27.1"
- For react-native part, I have these packages configured in my package.json to make graphql api calls.
"@aws-crypto/sha256-js": "^5.2.0",
"@aws-sdk/client-cognito-identity": "^3.840.0",
"react": "19.0.0",
"react-native": "0.78.2",
- When the API call initiates within react native part, the existing android app crashes with the log shared in the description section.
React Native Version
0.78.2
Affected Platforms
Runtime - Android
Output of npx @react-native-community/cli info
System:
OS: macOS 15.5
CPU: (14) arm64 Apple M4 Pro
Memory: 113.20 MB / 24.00 GB
Shell:
version: "5.9"
path: /bin/zsh
Binaries:
Node:
version: 20.19.3
path: ~/.nvm/versions/node/v20.19.3/bin/node
Yarn:
version: 1.22.22
path: ~/.nvm/versions/node/v20.19.3/bin/yarn
npm:
version: 10.8.2
path: ~/.nvm/versions/node/v20.19.3/bin/npm
Watchman:
version: 2025.06.30.00
path: /opt/homebrew/bin/watchman
Managers:
CocoaPods: Not Found
SDKs:
iOS SDK:
Platforms:
- DriverKit 24.5
- iOS 18.5
- macOS 15.5
- tvOS 18.5
- visionOS 2.5
- watchOS 11.5
Android SDK: Not Found
IDEs:
Android Studio: 2025.1 AI-251.25410.109.2511.13752376
Xcode:
version: 16.4/16F6
path: /usr/bin/xcodebuild
Languages:
Java:
version: 17.0.16
path: /Library/Java/JavaVirtualMachines/zulu-17.jdk/Contents/Home/bin/javac
Ruby:
version: 3.4.4
path: /opt/homebrew/opt/ruby/bin/ruby
npmPackages:
"@react-native-community/cli":
installed: 19.1.0
wanted: ^19.1.0
react:
installed: 19.0.0
wanted: 19.0.0
react-native:
installed: 0.78.2
wanted: 0.78.2
react-native-macos: Not Found
npmGlobalPackages:
"*react-native*": Not Found
Android:
hermesEnabled: true
newArchEnabled: true
iOS:
hermesEnabled: true
newArchEnabled: true
info React Native v0.80.2 is now available (your project is running on v0.78.2).
info Changelog: https://github.com/facebook/react-native/releases/tag/v0.80.2
info Diff: https://react-native-community.github.io/upgrade-helper/?from=0.78.2&to=0.80.2
info For more info, check out "https://reactnative.dev/docs/upgrading?os=macos".
Stacktrace or Logs
FATAL EXCEPTION: OkHttp Dispatcher (Ask Gemini) Process: com.ExampleApp.mobile.dev, PID: 30551 java.lang.NoClassDefFoundError: Failed resolution of: Lokhttp3/internal/Util; at okhttp3.JavaNetCookieJar.decodeHeaderAsJavaNetCookies(JavaNetCookieJar.kt:81) at okhttp3.JavaNetCookieJar.loadForRequest(JavaNetCookieJar.kt:59) at com.facebook.react.modules.network.ReactCookieJarContainer.loadForRequest(ReactCookieJarContainer.kt:37) at okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.kt:73) at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:126) at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.kt:72) at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:126) at okhttp3.internal.connection.RealCall.getResponseWithInterceptorChain$okhttp(RealCall.kt:203) at okhttp3.internal.connection.RealCall$AsyncCall.run(RealCall.kt:527) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1156) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:651) at java.lang.Thread.run(Thread.java:1119) Caused by: java.lang.ClassNotFoundException: Didn't find class "okhttp3.internal.Util" on path: DexPathList[[zip file "/data/app/~~VS4y1xXhJcA54X33Jpvdlg==/com.ExampleApp.mobile.dev-VsoAWRXrqWSlRrDRJ743IQ==/base.apk"],nativeLibraryDirectories=[/data/app/~~VS4y1xXhJcA54X33Jpvdlg==/com.ExampleApp.mobile.dev-VsoAWRXrqWSlRrDRJ743IQ==/lib/arm64, /data/app/~~VS4y1xXhJcA54X33Jpvdlg==/com.ExampleApp.mobile.dev-VsoAWRXrqWSlRrDRJ743IQ==/base.apk!/lib/arm64-v8a, /system/lib64, /system_ext/lib64]] at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:259) at java.lang.ClassLoader.loadClass(ClassLoader.java:637) at java.lang.ClassLoader.loadClass(ClassLoader.java:573)
MANDATORY Reproducer
I dont have a repo setup for this.
Screenshots and Videos
No response