Skip to content

Commit d8eed1b

Browse files
authored
fix(expo): add Kotlin metadata version compatibility flag for clerk-android (#8152)
1 parent d976a82 commit d8eed1b

2 files changed

Lines changed: 25 additions & 2 deletions

File tree

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@clerk/expo': patch
3+
---
4+
5+
Add `-Xskip-metadata-version-check` Kotlin compiler flag to resolve metadata version mismatch errors when building Android apps with Expo SDK 54/55. The `clerk-android` dependency is compiled with Kotlin 2.3.x while Expo ships Kotlin 2.1.x, causing `:app:compileDebugKotlin` to fail.

packages/expo/android/build.gradle

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,9 @@ android {
5454

5555
kotlinOptions {
5656
jvmTarget = "17"
57-
// clerk-android transitive deps (e.g. telemetry-api) still ship Kotlin 2.3.x metadata
57+
// TODO: Remove once clerk-android pins its transitive deps to a Kotlin version compatible with Expo.
58+
// clerk-android transitive deps (e.g. kotlinx-serialization-core:1.10.0) ship Kotlin 2.3.x metadata,
59+
// but Expo SDK 54/55 uses Kotlin 2.1.x. This flag lets the 2.1.x compiler read 2.3.x metadata safely.
5860
freeCompilerArgs += ['-Xskip-metadata-version-check']
5961
}
6062

@@ -75,7 +77,23 @@ android {
7577
}
7678
}
7779

78-
// Note: kotlin-stdlib exclusions are handled in the clerk-android-ui dependency declaration
80+
// clerk-android is compiled with Kotlin 2.3.x, but Expo/RN projects typically use an older
81+
// Kotlin version (e.g. 2.1.x). This causes "incompatible version of Kotlin" metadata errors
82+
// at :app:compileDebugKotlin. Applying -Xskip-metadata-version-check allows the older
83+
// compiler to read 2.3.x metadata without failing.
84+
try {
85+
rootProject.allprojects {
86+
tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).configureEach {
87+
compilerOptions {
88+
freeCompilerArgs.add('-Xskip-metadata-version-check')
89+
}
90+
}
91+
}
92+
} catch (Exception ignored) {
93+
// Future Gradle versions with Isolated Projects may block cross-project configuration.
94+
// In that case, users should add '@clerk/expo' to their app.json plugins array instead,
95+
// which applies the flag via the config plugin's withClerkAndroid.
96+
}
7997

8098
dependencies {
8199
// React Native

0 commit comments

Comments
 (0)