未找到 ID 为“com.facebook.react”的插件。
地点: 构建文件“android/app/build.gradle”行:2
出了什么问题: 评估项目“:app”时出现问题。
未找到 ID 为“com.facebook.react”的插件。
==============================================================================
* Get more help at https://help.gradle.org
BUILD FAILED in 3s
error Failed to install the app. Make sure you have the Android development environment set up: https://reactnative.dev/docs/environment-setup.
Error: Command failed: ./gradlew app:installDebug -PreactNativeDevServerPort=8081
FAILURE: Build completed with 2 failures.
1: Task failed with an exception.
-----------
* Where:
Build file 'android/app/build.gradle' line: 2
* What went wrong:
A problem occurred evaluating project ':app'.
> Plugin with id 'com.facebook.react' not found.
* 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.
==============================================================================
2: Task failed with an exception.
-----------
* What went wrong:
A problem occurred configuring project ':app'.
> compileSdkVersion is not specified. Please add it to build.gradle
* 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
我发现这个文档页面对于这个特定问题很有用,但它只是导致了一个新问题...我更普遍的问题的根源是我正在从较低版本的React Native升级,并且忘记了包括需要进行一些更改。解决此类问题的最佳方法是使用 React Native Upgrade Helper,它将使用示例应用程序准确地向您展示需要更改的内容。
我遇到了同样的问题,构建失败并显示错误消息:
Plugin with id 'com.facebook.react' not found.
这是在尝试评估build.gradle
中的项目“:app”时发生的。
对我有用的是删除
node_modules
目录,然后重新安装依赖项。以下是我遵循的步骤:
node_modules
目录:
rm -rf node_modules
npm cache clean --force
npm install
`