我在尝试构建 React Native 项目时遇到问题。构建过程失败并显示以下错误消息:
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':react-native-reanimated:compileDebugJavaWithJavac'.
> Could not resolve all files for configuration ':react-native-reanimated:androidJdkImage'.
> Failed to transform core-for-system-modules.jar to match attributes {artifactType=_internal_android_jdk_image, org.gradle.libraryelements=jar, org.gradle.usage=java-runtime}.
> Execution failed for JdkImageTransform: /Users/zeeshanahmad/Library/Android/sdk/platforms/android-34/core-for-system-modules.jar.
> Error while executing process /Library/Java/JavaVirtualMachines/jdk-21.jdk/Contents/Home/bin/jlink with arguments {--module-path /Users/zeeshanahmad/.gradle/caches/transforms-3/393400499b2af28f59d755a5f301569b/transformed/output/temp/jmod --add-modules java.base --output /Users/zeeshanahmad/.gradle/caches/transforms-3/393400499b2af28f59d755a5f301569b/transformed/output/jdkImage --disable-plugin system-modules}
我在下面提供了 package.json 文件的相关部分:
"@react-navigation/bottom-tabs": "^6.5.12",
"@react-navigation/native": "^6.1.10",
"@rneui/base": "^4.0.0-rc.7",
"@rneui/themed": "^4.0.0-rc.8",
"react": "18.2.0",
"react-native": "0.73.3",
"react-native-gesture-handler": "^2.15.0",
"react-native-reanimated": "^3.7.0",
"react-native-safe-area-context": "^4.9.0",
"react-native-screens": "^3.29.0",
"react-native-vector-icons": "^10.0.3"
它似乎与react-native-reanimated包有关,特别是在编译阶段(compileDebugJavaWithJavac)。我尝试将 React Native 和 React-native-reanimated 包更新到最新版本(分别为 0.73.3 和 ^3.7.0),但问题仍然存在。
任何有关如何解决此问题的见解或建议将不胜感激。谢谢!
尝试添加:
configurations.all {
resolutionStrategy {
force 'com.facebook.react:react-native:0.73.3'
}
}
到你的 android/build.gradle 文件。 有关解释,请参阅 react-native-reanimated#3743。