I'm trying to upgrade React native 0.75.1, using https://react-native-community.github.io/upgrade-helper, but I'm running into an error.
Settings file 'mobile/android/settings.gradle' line: 2
What went wrong:
Plugin [id: 'com.facebook.react.settings'] was not found in any of the following sources:Gradle Core Plugins (plugin is not in 'org.gradle' namespace)
Included Builds (No included builds contain this plugin)
Plugin Repositories (plugin dependency must include a version number for this source)
here is the file in Android > settings.gradle
pluginManagement { includeBuild("../node_modules/@react-native/gradle-plugin") }
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')
which is what is required from the react-native upgrade helper.
I tried commenting out the line and adding the plugin in android/app/build.gradle like so:
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:
A problem occurred evaluating settings 'android'.
Could not get unknown property 'com' for settings 'android' of typeorg.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?
check your @react-native/gradle-plugin resolution in yarn.lock/package-lock.json; if you have any lingering other than 0.75.1 (eg i have 0.74.1 left in there) you have to remove node_modules and regenerate your lock file
https://github.com/facebook/react-native/issues/46046#issuecomment-2291641341
I encountered the same error on Windows.
When I opened my project in Android Studio, it shown a warning:
Multiple Gradle daemons might be spawned because
the Gradle JDK and JAVA_HOME locations are different.
This resolved the issue for me:
JAVA_HOME environment variable to C:\Program Files\Android\Android Studio\jbrIf you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With