Error Plugin [id: 'com.facebook.react.settings'] was not found in any of the following sources:, ...
Categories:
Resolving 'Error Plugin [id: 'com.facebook.react.settings'] was not found' in React Native 0.75.1
![Hero image for Error Plugin [id: 'com.facebook.react.settings'] was not found in any of the following sources:, ...](/img/4bb7ffbf-hero.webp)
A comprehensive guide to fixing the 'Plugin [id: 'com.facebook.react.settings'] was not found' error encountered when upgrading to React Native 0.75.1, focusing on Gradle configuration.
Upgrading React Native projects can sometimes introduce unexpected build issues. A common error encountered when migrating to React Native version 0.75.1 (and potentially other versions) is Plugin [id: 'com.facebook.react.settings'] was not found in any of the following sources:
. This error typically arises during the Android build process and indicates a problem with how Gradle locates and applies React Native-specific plugins. This article will guide you through understanding the root cause and provide step-by-step solutions to resolve this issue.
Understanding the 'Plugin Not Found' Error
The error message Plugin [id: 'com.facebook.react.settings'] was not found
points directly to Gradle's inability to locate a specific plugin required by React Native. In recent versions of React Native, particularly around 0.75.x, there have been changes in how the Android build system is configured and how plugins are applied. This specific plugin, com.facebook.react.settings
, is crucial for configuring various aspects of the React Native Android build, including dependency management and project settings.
The primary reason for this error is often an outdated or incorrectly configured settings.gradle
file, or an issue with the build.gradle
files (both project-level and app-level) that prevents Gradle from properly discovering the React Native plugin's location. The plugin is usually provided by the React Native package itself, and Gradle needs to be told where to find it.
flowchart TD A[Start Android Build] --> B{Gradle Reads settings.gradle} B --> C{Gradle Reads project build.gradle} C --> D{Gradle Reads app build.gradle} D --> E{Plugin 'com.facebook.react.settings' Applied?} E -- No --> F[Error: Plugin Not Found] E -- Yes --> G[Build Continues] F --> H[Solution: Update Gradle Files] H --> B
Flowchart illustrating the Gradle build process and where the plugin error occurs.
Common Causes and Solutions
The 'Plugin not found' error is usually a symptom of one of two main problems: either the settings.gradle
file isn't correctly pointing to the React Native node modules, or the build.gradle
files are not applying the plugin in the expected way. Let's explore the solutions.
android/
directory. This allows you to revert if anything goes wrong during the upgrade process.Solution 1: Verify and Update settings.gradle
The settings.gradle
file is responsible for including external projects and modules into your Gradle build. For React Native, it's crucial that this file correctly points to the node_modules
directory where the React Native Android build logic resides. The apply from: new File(nodeModules, "react-native/react.gradle")
line is often the culprit if missing or incorrectly placed.
// android/settings.gradle
rootProject.name = 'YourProjectName'
apply from: new File(nodeModules, "react-native/react.gradle")
include ':app'
// Ensure this block is present and correctly configured
def reactNativeDir = new File(rootProject.projectDir, '../node_modules/react-native')
def nodeModules = new File(rootProject.projectDir, '../node_modules')
// If you have other modules, they might be included here as well
// For example, if you have a custom module 'my-custom-module':
// include ':my-custom-module'
// project(':my-custom-module').projectDir = new File(nodeModules, 'my-custom-module/android')
apply from: new File(nodeModules, "react-native/react.gradle")
line is critical. It imports the core React Native Gradle configurations, including the definition of the com.facebook.react.settings
plugin.Solution 2: Check Project-Level build.gradle
The project-level build.gradle
file (located at android/build.gradle
) defines global build configurations, repositories, and dependencies for all modules in your project. Ensure that the buildscript
and allprojects
blocks are correctly configured to include the necessary repositories where Gradle can find the React Native plugins and other dependencies.
// android/build.gradle
buildscript {
ext {
minSdkVersion = 21
compileSdkVersion = 34 // Or your target SDK version
targetSdkVersion = 34 // Or your target SDK version
kotlinVersion = '1.9.0' // Or the version specified by React Native upgrade helper
}
repositories {
google()
mavenCentral()
}
dependencies {
classpath("com.android.tools.build:gradle:8.1.1") // Or the version specified by React Native upgrade helper
classpath("com.facebook.react:react-native-gradle-plugin") // Ensure this is present
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:")
}
}
allprojects {
repositories {
mavenCentral()
google()
maven { url "https://www.jitpack.io" }
}
}
classpath("com.facebook.react:react-native-gradle-plugin")
line within the buildscript
dependencies. This plugin is essential for React Native 0.75.1+ and provides the com.facebook.react.settings
plugin.Solution 3: Update App-Level build.gradle
Finally, inspect your app-level build.gradle
file (located at android/app/build.gradle
). This file applies the plugins and configures the specific build settings for your application module. The com.facebook.react.settings
plugin is typically applied here.
// android/app/build.gradle
plugins {
id 'com.android.application'
id 'com.facebook.react.settings' // This is the plugin that was not found
id 'org.jetbrains.kotlin.android'
}
android {
// ... other configurations ...
}
dependencies {
// ... your dependencies ...
implementation "com.facebook.react:react-android"
// ... other react-native dependencies ...
}
cd android && ./gradlew clean
(or gradlew.bat clean
on Windows) followed by cd .. && npx react-native run-android
.1. Review settings.gradle
Open android/settings.gradle
and ensure it contains the apply from: new File(nodeModules, "react-native/react.gradle")
line and correctly defines nodeModules
.
2. Update Project build.gradle
Edit android/build.gradle
to include classpath("com.facebook.react:react-native-gradle-plugin")
in the buildscript
dependencies block.
3. Verify App build.gradle
Check android/app/build.gradle
to confirm that id 'com.facebook.react.settings'
is present in the plugins
block.
4. Clean and Rebuild
Navigate to your android
directory in the terminal (cd android
), run ./gradlew clean
(or gradlew.bat clean
), then return to your project root (cd ..
) and run npx react-native run-android
.