From a122f622d3a5183aa58a54c67a6310b2c2baa153 Mon Sep 17 00:00:00 2001 From: wobsoriano Date: Mon, 10 Aug 2026 00:35:02 -0700 Subject: [PATCH] fix(expo): Align Android OkHttp dependencies --- .changeset/fuzzy-badgers-align.md | 5 ++++ integration/templates/expo-native/app.json | 2 +- .../plugins/withClerkOkHttpAlignment.js | 26 ------------------- packages/expo/android/build.gradle | 14 +++++++++- 4 files changed, 19 insertions(+), 28 deletions(-) create mode 100644 .changeset/fuzzy-badgers-align.md delete mode 100644 integration/templates/expo-native/plugins/withClerkOkHttpAlignment.js diff --git a/.changeset/fuzzy-badgers-align.md b/.changeset/fuzzy-badgers-align.md new file mode 100644 index 00000000000..d65d7252593 --- /dev/null +++ b/.changeset/fuzzy-badgers-align.md @@ -0,0 +1,5 @@ +--- +'@clerk/expo': patch +--- + +Align Android OkHttp dependencies to compatible versions so Clerk native networking and React Native can run without a mixed OkHttp 4 and 5 classpath. diff --git a/integration/templates/expo-native/app.json b/integration/templates/expo-native/app.json index 9c378558907..58e258ea523 100644 --- a/integration/templates/expo-native/app.json +++ b/integration/templates/expo-native/app.json @@ -12,6 +12,6 @@ "android": { "package": "com.clerk.exponativebuildfixture" }, - "plugins": ["expo-secure-store", "@clerk/expo", "expo-web-browser", "./plugins/withClerkOkHttpAlignment.js"] + "plugins": ["expo-secure-store", "@clerk/expo", "expo-web-browser"] } } diff --git a/integration/templates/expo-native/plugins/withClerkOkHttpAlignment.js b/integration/templates/expo-native/plugins/withClerkOkHttpAlignment.js deleted file mode 100644 index 52337e8c960..00000000000 --- a/integration/templates/expo-native/plugins/withClerkOkHttpAlignment.js +++ /dev/null @@ -1,26 +0,0 @@ -const { withAppBuildGradle } = require('expo/config-plugins'); - -// clerk-android is compiled against OkHttp 5 but React Native pins OkHttp 4, -// leaving a mixed classpath: clerk networking breaks on the 4.x core -// (NoClassDefFoundError: okhttp3.internal.UnreadableResponseBody), while RN's -// cookie jar breaks on the 5.x core (okhttp3.internal.Util). Force the 5.x -// core plus the urlconnection shim that still ships a JavaNetCookieJar class -// compatible with it, so both stacks run on one coherent OkHttp. -const GRADLE_BLOCK = ` -configurations.all { - resolutionStrategy { - force 'com.squareup.okhttp3:okhttp:5.4.0' - force 'com.squareup.okhttp3:logging-interceptor:5.4.0' - force 'com.squareup.okhttp3:okhttp-urlconnection:5.0.0-alpha.16' - } -} -`; - -module.exports = function withClerkOkHttpAlignment(config) { - return withAppBuildGradle(config, cfg => { - if (!cfg.modResults.contents.includes('com.squareup.okhttp3:okhttp:5.4.0')) { - cfg.modResults.contents += GRADLE_BLOCK; - } - return cfg; - }); -}; diff --git a/packages/expo/android/build.gradle b/packages/expo/android/build.gradle index 3ebd4c78ec0..871c8571d29 100644 --- a/packages/expo/android/build.gradle +++ b/packages/expo/android/build.gradle @@ -22,6 +22,8 @@ ext { kotlinxCoroutinesVersion = "1.7.3" clerkAndroidApiVersion = "1.0.39" clerkAndroidUiVersion = "1.0.39" + okhttpVersion = "5.4.0" + okhttpUrlConnectionVersion = "5.0.0-alpha.16" composeVersion = "1.7.0" activityComposeVersion = "1.9.0" lifecycleVersion = "2.8.0" @@ -107,7 +109,7 @@ dependencies { // Clerk Android SDK with prebuilt UI // Exclude kotlin-stdlib to prevent 2.3.0 from polluting the project - // Exclude okhttp to prevent version conflict with React Native's okhttp + // Exclude transitive OkHttp modules so the compatible versions below control resolution. implementation("com.clerk:clerk-android-ui:$clerkAndroidUiVersion") { exclude group: 'org.jetbrains.kotlin', module: 'kotlin-stdlib' exclude group: 'org.jetbrains.kotlin', module: 'kotlin-stdlib-jdk7' @@ -126,6 +128,16 @@ dependencies { exclude group: 'com.squareup.okhttp3', module: 'okhttp-urlconnection' } + implementation('com.squareup.okhttp3:okhttp') { + version { strictly(okhttpVersion) } + } + implementation('com.squareup.okhttp3:logging-interceptor') { + version { strictly(okhttpVersion) } + } + implementation('com.squareup.okhttp3:okhttp-urlconnection') { + version { strictly(okhttpUrlConnectionVersion) } + } + // Jetpack Compose for wrapping Clerk views implementation "androidx.compose.ui:ui:$composeVersion" implementation "androidx.compose.material3:material3:1.3.0"