尝试使用 https://react-native-community.github.io/upgrade-helper.
升级 React Native 0.75.1遇到错误
设置文件“mobile/android/settings.gradle”行:2
出了什么问题: 在以下任何来源中均未找到插件 [id: 'com.facebook.react.settings']:
Gradle 核心插件(插件不在“org.gradle”命名空间中)
包含的构建(没有包含的构建包含此插件)
插件存储库(插件依赖项必须包含此源的版本号)
这里是文件 android>settings.gradle
plugins { id("com.facebook.react.settings") }
extensions.configure(com.facebook.react.ReactSettingsExtension){ ex -> ex.autolinkLibrariesFromCommand() }
rootProject.name = 'mobileAppName'
include ':app'
includeBuild('../node_modules/@react-native/gradle-plugin')
这是react-native升级助手所需要的。 尝试注释掉该行并在 android/app/build.gradle 中添加插件 像这样
apply plugin: "com.facebook.react"
apply plugin: "com.facebook.react.settings"
apply plugin: "com.google.gms.google-services"
apply plugin: "com.google.firebase.crashlytics"
apply plugin: 'com.google.firebase.firebase-perf'
apply plugin: "org.jetbrains.kotlin.android"```
but the next line errors out
* What went wrong:
A problem occurred evaluating settings 'android'.
> Could not get unknown property 'com' for settings 'android' of type org.gradle.initialization.DefaultSettings.
from line
extensions.configure(com.facebook.react.ReactSettingsExtension){ ex -> ex.autolinkLibrariesFromCommand() }
so the plugin has to be imported in settings.gradle
does anyone have a solution or workaround to get the plugin "com.facebook.react.settings") working??
我在 Windows 上遇到了同样的错误。
当我在 Android Studio 中打开我的项目时,它显示了一条警告:
Multiple Gradle daemons might be spawned because
the Gradle JDK and JAVA_HOME locations are different.
这解决了我的问题:
JAVA_HOME
环境变量设置为 C:\Program Files\Android\Android Studio\jbr