Skip to content

Amplify OkHttp Version Conflict with React Native Brownfield Android App #3099

@shishirchulliyil

Description

@shishirchulliyil

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:

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.x 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 supporting older OkHttp version like 4.9.2 ?

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions