react-native: Issue building android duplicate versions of jetified-kotlin-stdlib-1
Description
running npx react-native android
I get the following error:
Execution failed for task ':app:mergeDebugJavaResource'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
> More than one file was found with OS independent path 'META-INF/kotlin-stdlib-jdk7.kotlin_module'.
This repros in CI as well
Version
0.63.5
Output of npx react-native info
System: OS: macOS 13.0.1 CPU: (16) x64 Intel® Core™ i9-9880H CPU @ 2.30GHz Memory: 136.32 MB / 16.00 GB Shell: 5.8.1 - /bin/zsh Binaries: Node: 14.18.0 - ~/.nvm/versions/node/v14.18.0/bin/node Yarn: 1.22.18 - /usr/local/bin/yarn npm: 8.19.2 - ~/.nvm/versions/node/v14.18.0/bin/npm Watchman: 2022.09.19.00 - /usr/local/bin/watchman Managers: CocoaPods: 1.11.3 - /usr/local/bin/pod SDKs: iOS SDK: Platforms: DriverKit 22.2, iOS 16.2, macOS 13.1, tvOS 16.1, watchOS 9.1 Android SDK: Not Found IDEs: Android Studio: 4.2 AI-202.7660.26.42.7351085 Xcode: 14.2/14C18 - /usr/bin/xcodebuild Languages: Java: 11.0.16.1 - /usr/bin/javac Python: 3.10.3 - /Users/Jake/.pyenv/shims/python npmPackages: @react-native-community/cli: Not Found react: 16.13.1 => 16.13.1 react-native: 0.63.5 => 0.63.5 react-native-macos: Not Found npmGlobalPackages: react-native: Not Found
Steps to reproduce
npx react-native android
Snack, code example, screenshot, or link to a repository
NA
About this issue
- Original URL
- State: closed
- Created a year ago
- Reactions: 14
- Comments: 24 (1 by maintainers)
Links to this issue
Commits related to this issue
- fix: duplicate versions of jetified-kotlin-stdlib-1 when building android version This fix comes from https://github.com/facebook/react-native/issues/35979 — committed to cozy/cozy-flagship-app by deleted user a year ago
- fix: duplicate versions of jetified-kotlin-stdlib-1 when building android version This fix comes from https://github.com/facebook/react-native/issues/35979 — committed to cozy/cozy-flagship-app by deleted user a year ago
This fix worked for me in the meantime:
(android/app/build.gradle)
I think if using a modern Kotlin Gradle Plugin you can also add the Gradle property
kotlin.stdlib.jdk.variants.version.alignment=false
(https://kotlinlang.org/docs/whatsnew18.html#usage-of-the-latest-kotlin-stdlib-version-in-transitive-dependencies)Below fixed work for me.
Checkout here
In my company’s case I did a comparison of the gradle dependency graph to identify what introduced the change in the build dependencies.
The problem, in our case, was introduced by this library’s use of a version wildcard: https://github.com/proyecto26/react-native-inappbrowser/issues/398
And the solution we went with was to specify
androidXAnnotation = "1.5.0"
as anext
in theandroid/build.gradle
fileI thought I was the only one, I have also been getting this same issue since today.
this should be the best workaround
Closing as the workaround is reported as working fine.
This worked for me.
Saved my day
This worked for me, thanks!
Me too. But I sinceraly don’t understand why after creation Java-project with Android Studio’s wizard I have any problems with Kotlin.
I believe this is the same issue I’ve been battling with for a couple of hours now.
I found a potential fix of upgrading kotlinVersion to 1.8.0 in build.gradle, but that didn’t help. Apparently because React Native has version 1.4.10 on it.