升级到“react-native”时,在以下任何来源中都找不到错误插件[id:'com.facebook.react.settings']:“0.75.1”

问题描述 投票:0回答:1

尝试使用 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??


android react-native gradle build.gradle
1个回答
0
投票

我在 Windows 上遇到了同样的错误。

当我在 Android Studio 中打开我的项目时,它显示了一条警告:

Multiple Gradle daemons might be spawned because
the Gradle JDK and JAVA_HOME locations are different.

这解决了我的问题:

  1. JAVA_HOME
    环境变量设置为
    C:\Program Files\Android\Android Studio\jbr
  2. 重启VSCode
© www.soinside.com 2019 - 2024. All rights reserved.