Error Plugin [id: 'com.facebook.react.settings'] was not found in any of the following sources:, when upgrading to "react-native": "0.75.1"
Asked Answered
M

7

7

Trying to upgrade react native 0.75.1, using https://react-native-community.github.io/upgrade-helper.

running into 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 file 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. tried commenting out the line and adding the plugin in android/app/build.gradle like so

apply plugin: "com.android.application"
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??

Manage answered 16/8, 2024 at 18:5 Comment(0)
S
6

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

Sybilsybila answered 19/8, 2024 at 13:11 Comment(0)
M
2

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:

  1. Set JAVA_HOME environment variable to C:\Program Files\Android\Android Studio\jbr
  2. Restart VSCode
Melon answered 17/8, 2024 at 20:4 Comment(0)
H
2

I had the same issue

this is my android>settings.gradle file

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 = 'InAppPurchase'
include ':app'
includeBuild('../node_modules/@react-native/gradle-plugin')

I updated the @react-native/gradle-plugin to latest version but it did not solve the issue.

when I run npm run android instead of npm start this worked in my case.

Herv answered 13/9, 2024 at 9:52 Comment(0)
K
1

Downgrade the distributionUrl in android/gradle/wrapper/gradle-wrapper.properties and rebuild your project. From gradle-8.8-all.zip to gradle-8.5-all.zip or compatibility version

Or you can try the trick: https://github.com/facebook/metro/issues/1328#issuecomment-2302466257

Koerner answered 22/8, 2024 at 10:50 Comment(0)
S
0

I was also getting the same error got the fix

after installing node_modules / setup of react native project close your terminal and in new terminal run below command this works for me

npm run android --clear-cache

Scandic answered 3/9, 2024 at 15:13 Comment(0)
M
0

I just deleted .gradle folder from android folder and run "npm run android" again and it worked.

Myungmyxedema answered 27/9, 2024 at 6:12 Comment(0)
A
0

I fixed this issue by updating node js version.

run following command to update:

choco install nodejs --version="22.9.0" // run this in command prompt as administrator
Antisthenes answered 3/10, 2024 at 11:26 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.