15

We are currently working with React-Native 0.68.5, Windows 10 and are getting this error when trying to build the gradle file:

Could not resolve all task dependencies for configuration ':classpath'. > Could not find com.facebook.react:react-native-gradle-plugin:.

So far we have tried different versions of com.android.tools.build:gradle, as well as installing 'react-native-gradle-plugin' manually to package.json, also tried deleting the '.gradle' folder and rebuilding it but so far none have worked. Looking for insights from anyone who has faced this issue before and how you were able to resolve it (https://i.sstatic.net/5cKSj.png)

(https://i.sstatic.net/LEqmq.png)

(https://i.sstatic.net/nhPZX.png)

(https://i.sstatic.net/nK4Gl.png)

12 Answers 12

30

After you reinstall node_modules with updated package.json to support latest (0.71) react native, you need to edit your settings.gradle file by adding this line:

includeBuild('../node_modules/react-native-gradle-plugin')

Then go to Android folder. And clean the Android folder using ./gradlew clean command and run build, maybe this will help fix your issue.

2
  • 7
    For 0.72, it's there is an @: includeBuild('../node_modules/@react-native/gradle-plugin')
    – Elijah
    Commented Aug 2, 2023 at 15:11
  • 1
    This was the solution for me!
    – D.Steinel
    Commented Nov 30, 2023 at 10:40
12

Simply deleting node_modules and runing npm install works for me

Steps in windows in the root of the project.

rmdir /s node_modules

npm install
0
1

Deleting the node_modules folder and re downloading it worked for me.

2
  • 2
    Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.
    – Community Bot
    Commented Jan 31, 2023 at 7:09
  • 1
    stop provide delete node_modules folder as it's useless answer
    – famfamfam
    Commented Jun 13, 2023 at 7:40
0
  1. Try deleting all of your node_modules folder in your project.
  2. Go to Android folder. And clean the Android folder using ./gradlew clean command
  3. rebuild the app on project root folder
5
  • Thank you Samuel! I tried deleting the node_modules folder and running ./gradlew clean from the android folder but am getting errors referencing the settings.gradle file, where it's looking for 'node_modules\@react-native-community\cli-platform-android\native_modules.gradle'. Should I run 'npm install' first after deleting the node_modules folder before running './gradlew clean'?
    – stackdev33
    Commented Dec 21, 2022 at 20:25
  • Tried running the './gradlew clean' command with npm install: FAILURE: Build failed with an exception. * Where: Build file 'xx \node_modules\react-native-gradle-plugin\build.gradle.kts' line: 11 * What went wrong: Plugin [id: 'org.jetbrains.kotlin.jvm', version: '1.6.10'] was not found in any of the following sources: - Gradle Core Plugins (plugin is not in 'org.gradle' namespace) - Included Builds (None of the included builds contain this plugin) - Plugin Repositories (could not resolve plugin artifact 'org.jetbrains.kotlin.jvm:org.jetbrains.kotlin.jvm.gradle.plugin:1.6.10')
    – stackdev33
    Commented Dec 21, 2022 at 22:01
  • 1
    Deleting the node_modules folder, run ./gradlew clean.
    – Samuel Lee
    Commented Dec 22, 2022 at 6:34
  • After that, install node_modules and open the Android Folder in Android Studio. It will fix the issues automatically. And run the app
    – Samuel Lee
    Commented Dec 22, 2022 at 6:35
  • 1
    If you can't run ./gradlew clean, use this command rm -rf android/build android/app/build
    – Samuel Lee
    Commented Dec 22, 2022 at 6:49
0

The first thing you need to do is try to delete your .gradle folder and then run your project again. If you still face the same error, then try to delete your node_modules folder and then add your packages again by running yarn install or npm install whatever package manager you are using and after that run your project again.

1
0

After removing the following code in android/build.gradle it worked:

exclusiveContent {
               filter {
                   includeGroup "com.facebook.react"
               }
               forRepository {
                   maven {
                       url "$rootDir/../node_modules/react-native/android"
                   }
               }
        }

NOTE: if above answer is not working so please try this one (remove this code)

allprojects {
    configurations.all {
        resolutionStrategy {
            force "com.facebook.react:react-native:" + REACT_NATIVE_VERSION
        }
    }
    ```
    
0

This happened with me when I created a new React Native bare project(CLI) and installed navigation libraries, I solved it with 3 steps 1 - deleting Node-modules 2 - reinstalling them 3 - Cleaning android with ' cd android ' and then running ' ./gradlew clean ' command .

0

I needed to add the code below to the settings.gradle file.

includeBuild('../node_modules/react-native-gradle-plugin')
0

I worked on the windows terminal not on vs code inbuild then in android folder run this command :

gradlew clean

then if it runs successfully then you can again build your project from windows terminal only. I did this and worked for me.

0

Solution: To resolve this, follow these steps:

Navigate to the android directory:

cd android

./gradlew.bat

./gradlew clean

cd ..

Reset the Metro bundler cache: Resetting the cache helps avoid bundler-related problems:

npx react-native start --reset-cache or
npx react-native run-android
0

I update from 0.62.2 to 0.76.1 have same issue so i add includeBuild('../node_modules/react-native-gradle-plugin') in settings.gradle is worked. run yarn why react-native-gradle-plugin if have path is success.

-3

Instead of opening cmd in normal mode, open cmd in Run As Administrator mode. This is how I fixed the issue:

  1. Open cmd (Command Prompt) in Run As Administrator mode
  2. Run the command : npx react-native run-android
  3. And rest of the steps remain the same.

Note:- If you are creating a new application using CLI, open cmd in Run As Administrator mode. The syntax of command used to create a new application is: npx react-native init Project_Name

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.