Skip to content

React Native OkHttp Version Conflict with Android AWS Amplify for Brownfield RN Android App #52945

Closed

Description

@shishirchulliyil

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

  1. Install react native template for brownfield app from the community repo : https://github.com/react-native-community/template/tree/0.78-stable/template
  2. 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"
  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",
  1. 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

Activity

  1. added
    Needs: Repro
    Platform: Android
    🌐Networking
    on Jul 31, 2025
  2. react-native-bot commented on Jul 31, 2025

    @react-native-bot
    Collaborator

    Warning

    Missing reproducer: We could not detect a reproducible example in your issue report. Reproducers are mandatory and we can accept only one of those as a valid reproducer:


    You can read more about about it on our website: How to report a bug.

  3. cortinico commented on Aug 1, 2025

    @cortinico
    Contributor

    Copying my response from here: react-native-community/template#164

    AWS Amplify Android SDK (2.27.1): Requires OkHttp 5.0.0-alpha.11 (or higher).

    This is clearly a problem of AWS Amplify. Why do they hard require OkHTTP 5?
    By requiring OkHTTP they're effectively breaking the whole RN ecosystem.

    Have you opened an issue against them? If yes, please link it there.

    Also, what is the incompatibility you're talking about.
    Can you share the build failure?

  4. react-native-bot commented on Aug 26, 2025

    @react-native-bot
    Collaborator

    This issue is waiting for author's feedback since 24 days. Please provide the requested feedback or this will be closed in 7 days.

  5. added
    Stale
    and removed
    Stale
    on Aug 26, 2025
  6. cortinico commented on Aug 27, 2025

    @cortinico
    Contributor

    @shishirchulliyil have you ended up opening an issue with AWS amplify?

  7. anandvarkeyphilips commented on Sep 13, 2025

    @anandvarkeyphilips

    @cortinico , Is there any plan for upgrading OkHTTP to version 5 soon?
    I think it would be really beneficial.
    Context: Happy Eyeballs (RFC 6555) Algorithm implemented, which improves loading times on requests between IPv6 and IPv4.

    I see your comment here:
    #33045 (comment)

  8. cortinico commented on Sep 14, 2025

    @cortinico
    Contributor

    @cortinico , Is there any plan for upgrading OkHTTP to version 5 soon?

    Nope no immediate plans to update OkHTTP to 5.

  9. react-native-bot commented on Oct 9, 2025

    @react-native-bot
    Collaborator

    This issue is waiting for author's feedback since 24 days. Please provide the requested feedback or this will be closed in 7 days.

  10. added
    Stale
    and removed
    Stale
    on Oct 9, 2025
  11. react-native-bot commented on Nov 2, 2025

    @react-native-bot
    Collaborator

    This issue is waiting for author's feedback since 24 days. Please provide the requested feedback or this will be closed in 7 days.

  12. added
    Stale
    and removed
    Stale
    on Nov 2, 2025
  13. mtroskot commented on Jan 17, 2026

    @mtroskot

    @cortinico
    I have the same issue with another Android SDK (Adyen POS SDK) in my React Native app—it requires OkHttp 5. Creating issues on external SDK repositories isn't a practical solution, as they have valid reasons to use OkHttp 5.
    A workaround or patch for upgrading React Native's OkHttp version would help bridge this gap until official support is available.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Needs: Author FeedbackNeeds: ReproPlatform: Android🌐Networking

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions