我试图在我的macOS中运行一个react-native项目。我已经完成了npm install uninstall,clean gradle,但仍然面临同样的问题。
当我运行npm start时,我遇到了下面的问题。
info Opening the app on Android...
info JS server already running.
info Installing the app...
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring project ':react-native-gradle-plugin'.
> Could not create service of type OutputFilesRepository using ExecutionGradleServices.createOutputFilesRepository().
> Failed to create parent directory '/Users/ealpha4tech/Downloads/ealpha4-mobile-main 2/node_modules/react-native-gradle-plugin/.gradle' when creating directory '/Users/ealpha4tech/Downloads/ealpha4-mobile-main 2/node_modules/react-native-gradle-plugin/.gradle/buildOutputCleanup'
* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 6s
Error: Command failed: ./gradlew app:installDebug -PreactNativeDevServerPort=8081
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring project ':react-native-gradle-plugin'.
> Could not create service of type OutputFilesRepository using ExecutionGradleServices.createOutputFilesRepository().
> Failed to create parent directory '/Users/ealpha4tech/Downloads/ealpha4-mobile-main 2/node_modules/react-native-gradle-plugin/.gradle' when creating directory '/Users/ealpha4tech/Downloads/ealpha4-mobile-main 2/node_modules/react-native-gradle-plugin/.gradle/buildOutputCleanup'
* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 6s
at makeError (/Users/ealpha4tech/Downloads/ealpha4-mobile-main 2/node_modules/@react-native-community/cli-platform-android/node_modules/execa/index.js:174:9)
at /Users/ealpha4tech/Downloads/ealpha4-mobile-main 2/node_modules/@react-native-community/cli-platform-android/node_modules/execa/index.js:278:16
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async runOnAllDevices (/Users/ealpha4tech/Downloads/ealpha4-mobile-main 2/node_modules/@react-native-community/cli-platform-android/build/commands/runAndroid/runOnAllDevices.js:82:7)
at async Command.handleAction (/Users/ealpha4tech/Downloads/ealpha4-mobile-main 2/node_modules/@react-native-community/cli/build/index.js:108:9)
info Run CLI with --verbose flag for more details.
字符串
我不知道在为react-native设置环境时出了什么问题,或者我错过了哪一步。
从npm start运行ios app也会返回类似的结果。
The workspace named "ealpha" does not contain a scheme named "ealpha". The "-list" option can be used to find the names of the schemes in the workspace.
型
已编辑-
现在我得到了下面的错误。
* What went wrong:
Could not open settings generic class cache for settings file '/Users/ealpha4tech/Downloads/ealpha4-mobile-main 2/android/settings.gradle' (/Users/ealpha4tech/.gradle/caches/7.5.1/scripts/bx94o9il2py3wpbok5l2mnec2).
> BUG! exception in phase 'semantic analysis' in source unit '_BuildScript_' Unsupported class file major version 65
型
1条答案
按热度按时间a1o7rhls1#
解决方案1
1.链接:https://github.com/facebook/react-native/issues/34410
1.链接:https://github.com/facebook/react-native/issues/38034
解决方案2
1.清理Gradle缓存:这有时可以解决Gradle问题。为此,请运行命令:./gradlew clean或gradle clean
1.考虑重建项目。通过这样做,Gradle将被迫从fresh重建项目并下载任何缺少的依赖项。使用以下命令来完成此操作:gradle build或./gradle build
解决方案3
1.您可以使用以下命令删除当前安装的JDK(MacOS):
sudo rm -rf /Library/Java/JavaVirtualMachines/jdk.jdk接下来,从Oracle官方网站下载并启动应用程序。