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

32

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.

Sign up to request clarification or add additional context in comments.

2 Comments

For 0.72, it's there is an @: includeBuild('../node_modules/@react-native/gradle-plugin')
This was the solution for me!
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

Comments

1

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

2 Comments

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.
stop provide delete node_modules folder as it's useless answer
1

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

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

Comments

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 Comments

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'?
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')
Deleting the node_modules folder, run ./gradlew clean.
After that, install node_modules and open the Android Folder in Android Studio. It will fix the issues automatically. And run the app
If you can't run ./gradlew clean, use this command rm -rf android/build android/app/build
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 Comment

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
        }
    }
    ```
    

Comments

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 .

Comments

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.

Comments

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

Comments

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.

Comments

-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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.