OiO.lk Community platform!

Oio.lk is an excellent forum for developers, providing a wide range of resources, discussions, and support for those in the developer community. Join oio.lk today to connect with like-minded professionals, share insights, and stay updated on the latest trends and technologies in the development field.
  You need to log in or register to access the solved answers to this problem.
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation

Failed to apply plugin 'com.facebook.react.rootproject'

  • Thread starter Thread starter kindasthino
  • Start date Start date
K

kindasthino

Guest
I tried to build development build onto my emulator, yesterday it did fine. But today it got me this error:

  • What went wrong: A problem occurred evaluating root project 'xxx'.
Failed to apply plugin 'com.facebook.react.rootproject'. A problem occurred configuring project ':app'. Could not load compiled classes for build file

build.gradle

Code:
// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
ext {
buildToolsVersion = findProperty('android.buildToolsVersion') ?: '34.0.0'
minSdkVersion = Integer.parseInt(findProperty('android.minSdkVersion') ?: '23')
compileSdkVersion = Integer.parseInt(findProperty('android.compileSdkVersion') ?: '34')
targetSdkVersion = Integer.parseInt(findProperty('android.targetSdkVersion') ?: '34')
kotlinVersion = findProperty('android.kotlinVersion') ?: '1.8.10'

        ndkVersion = "25.1.8937393"
    }
    repositories {
        mavenCentral()
        google()
    }
    dependencies {
        classpath('com.android.tools.build:gradle')
        classpath('com.facebook.react:react-native-gradle-plugin')
    }

}

apply plugin: "com.facebook.react.rootproject"

allprojects {
repositories {
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url(new File(\['node', '--print', "require.resolve('react-native/package.json')"\].execute(null, rootDir).text.trim(), '../android'))
}
maven {
// Android JSC is installed from npm
url(new File(\['node', '--print', "require.resolve('jsc-android/package.json', { paths: \[require.resolve('react-native/package.json')\] })"\].execute(null, rootDir).text.trim(), '../dist'))
}

        google()
        mavenCentral()
        maven { url 'https://jitpack.io' }
    }

}

I tried to basically go through all the gradle files to find what might be causing this error but not any luck

<p>I tried to build development build onto my emulator, yesterday it did fine. But today it got me this error:</p>
<ul>
<li>What went wrong:
A problem occurred evaluating root project 'xxx'.</li>
</ul>
<blockquote>
<p>Failed to apply plugin 'com.facebook.react.rootproject'.
A problem occurred configuring project ':app'.
Could not load compiled classes for build file</p>
</blockquote>
<p>build.gradle</p>
<pre><code>// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
ext {
buildToolsVersion = findProperty('android.buildToolsVersion') ?: '34.0.0'
minSdkVersion = Integer.parseInt(findProperty('android.minSdkVersion') ?: '23')
compileSdkVersion = Integer.parseInt(findProperty('android.compileSdkVersion') ?: '34')
targetSdkVersion = Integer.parseInt(findProperty('android.targetSdkVersion') ?: '34')
kotlinVersion = findProperty('android.kotlinVersion') ?: '1.8.10'

ndkVersion = "25.1.8937393"
}
repositories {
mavenCentral()
google()
}
dependencies {
classpath('com.android.tools.build:gradle')
classpath('com.facebook.react:react-native-gradle-plugin')
}

}

apply plugin: "com.facebook.react.rootproject"

allprojects {
repositories {
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url(new File(\['node', '--print', "require.resolve('react-native/package.json')"\].execute(null, rootDir).text.trim(), '../android'))
}
maven {
// Android JSC is installed from npm
url(new File(\['node', '--print', "require.resolve('jsc-android/package.json', { paths: \[require.resolve('react-native/package.json')\] })"\].execute(null, rootDir).text.trim(), '../dist'))
}

google()
mavenCentral()
maven { url 'https://jitpack.io' }
}

}
</code></pre>
<p>I tried to basically go through all the gradle files to find what might be causing this error but not any luck</p>
 
I tried to build development build onto my emulator, yesterday it did fine. But today it got me this error:

  • What went wrong: A problem occurred evaluating root project 'xxx'.


build.gradle

Code:
// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
ext {
buildToolsVersion = findProperty('android.buildToolsVersion') ?: '34.0.0'
minSdkVersion = Integer.parseInt(findProperty('android.minSdkVersion') ?: '23')
compileSdkVersion = Integer.parseInt(findProperty('android.compileSdkVersion') ?: '34')
targetSdkVersion = Integer.parseInt(findProperty('android.targetSdkVersion') ?: '34')
kotlinVersion = findProperty('android.kotlinVersion') ?: '1.8.10'

        ndkVersion = "25.1.8937393"
    }
    repositories {
        mavenCentral()
        google()
    }
    dependencies {
        classpath('com.android.tools.build:gradle')
        classpath('com.facebook.react:react-native-gradle-plugin')
    }

}

apply plugin: "com.facebook.react.rootproject"

allprojects {
repositories {
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url(new File(\['node', '--print', "require.resolve('react-native/package.json')"\].execute(null, rootDir).text.trim(), '../android'))
}
maven {
// Android JSC is installed from npm
url(new File(\['node', '--print', "require.resolve('jsc-android/package.json', { paths: \[require.resolve('react-native/package.json')\] })"\].execute(null, rootDir).text.trim(), '../dist'))
}

        google()
        mavenCentral()
        maven { url 'https://jitpack.io' }
    }

}

I tried to basically go through all the gradle files to find what might be causing this error but not any luck

<p>I tried to build development build onto my emulator, yesterday it did fine. But today it got me this error:</p>
<ul>
<li>What went wrong:
A problem occurred evaluating root project 'xxx'.</li>
</ul>
<blockquote>
<p>Failed to apply plugin 'com.facebook.react.rootproject'.
A problem occurred configuring project ':app'.
Could not load compiled classes for build file</p>
</blockquote>
<p>build.gradle</p>
<pre><code>// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
ext {
buildToolsVersion = findProperty('android.buildToolsVersion') ?: '34.0.0'
minSdkVersion = Integer.parseInt(findProperty('android.minSdkVersion') ?: '23')
compileSdkVersion = Integer.parseInt(findProperty('android.compileSdkVersion') ?: '34')
targetSdkVersion = Integer.parseInt(findProperty('android.targetSdkVersion') ?: '34')
kotlinVersion = findProperty('android.kotlinVersion') ?: '1.8.10'

ndkVersion = "25.1.8937393"
}
repositories {
mavenCentral()
google()
}
dependencies {
classpath('com.android.tools.build:gradle')
classpath('com.facebook.react:react-native-gradle-plugin')
}

}

apply plugin: "com.facebook.react.rootproject"

allprojects {
repositories {
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url(new File(\['node', '--print', "require.resolve('react-native/package.json')"\].execute(null, rootDir).text.trim(), '../android'))
}
maven {
// Android JSC is installed from npm
url(new File(\['node', '--print', "require.resolve('jsc-android/package.json', { paths: \[require.resolve('react-native/package.json')\] })"\].execute(null, rootDir).text.trim(), '../dist'))
}

google()
mavenCentral()
maven { url 'https://jitpack.io' }
}

}
</code></pre>
<p>I tried to basically go through all the gradle files to find what might be causing this error but not any luck</p>
The error message you're encountering suggests that there's an issue with applying the com.facebook.react.rootproject plugin or configuring the :app project. This can happen due to various reasons, such as updates or changes in dependencies, cached files, or the build environment.

Here are some steps to diagnose and resolve the issue:

1.​

Sometimes, the Gradle cache can cause issues. Clearing it might help resolve the problem.

sh
Copy code
./gradlew clean<br>
You can also manually delete the .gradle and build directories in the project root and the app module:

sh
Copy code
<span>rm</span> -rf .gradle<br><span>rm</span> -rf app/build<br>

2.​

Ensure that the Gradle plugin versions are compatible with your project setup. Update your build.gradle with specific versions if needed.

groovy
Copy code
buildscript {<br> ext {<br> buildToolsVersion = "34.0.0"<br> minSdkVersion = 23<br> compileSdkVersion = 34<br> targetSdkVersion = 34<br> kotlinVersion = "1.8.10"<br> ndkVersion = "25.1.8937393"<br> }<br> repositories {<br> google()<br> mavenCentral()<br> }<br> dependencies {<br> classpath 'com.android.tools.build:gradle:8.0.2'<br> classpath 'com.facebook.react:react-native-gradle-plugin:0.72.2'<br> }<br>}<br>

3.​

The url methods in the allprojects.repositories block execute Node.js scripts to resolve paths. Ensure these paths are correct and that Node.js is installed and working properly.

groovy
Copy code
allprojects {<br> repositories {<br> maven {<br> url(new File(['node', '--print', "require.resolve('react-native/package.json')"].execute(null, rootDir).text.trim(), '../android'))<br> }<br> maven {<br> url(new File(['node', '--print', "require.resolve('jsc-android/package.json', { paths: [require.resolve('react-native/package.json')] })"].execute(null, rootDir).text.trim(), '../dist'))<br> }<br> google()<br> mavenCentral()<br> maven { url 'https://jitpack.io' }<br> }<br>}<br>

4.​

Ensure you are using the latest stable version of React Native and its associated plugins.

sh
Copy code
npm install react-native@latest<br>

5.​

Sometimes, network issues can cause problems while downloading dependencies. Ensure you have a stable internet connection.

6.​

After making changes, sync your project with Gradle files in Android Studio:

  • Open Android Studio.
  • Click on File &gt; Sync Project with Gradle Files.

7.​

Examine the detailed error logs to pinpoint where the issue occurs. The specific line number and error message can provide clues.

8.​

Finally, try to rebuild the project:

sh
Copy code
./gradlew clean build<br>

Example Updated​

Here’s a revised version of your build.gradle file:

groovy
Copy code
// Top-level build file where you can add configuration options common to all sub-projects/modules.<br><br>buildscript {<br> ext {<br> buildToolsVersion = '34.0.0'<br> minSdkVersion = 23<br> compileSdkVersion = 34<br> targetSdkVersion = 34<br> kotlinVersion = '1.8.10'<br> ndkVersion = '25.1.8937393'<br> }<br> repositories {<br> google()<br> mavenCentral()<br> }<br> dependencies {<br> classpath 'com.android.tools.build:gradle:8.0.2'<br> classpath 'com.facebook.react:react-native-gradle-plugin:0.72.2'<br> }<br>}<br><br>apply plugin: "com.facebook.react.rootproject"<br><br>allprojects {<br> repositories {<br> maven {<br> url(new File(['node', '--print', "require.resolve('react-native/package.json')"].execute(null, rootDir).text.trim(), '../android'))<br> }<br> maven {<br> url(new File(['node', '--print', "require.resolve('jsc-android/package.json', { paths: [require.resolve('react-native/package.json')] })"].execute(null, rootDir).text.trim(), '../dist'))<br> }<br> google()<br> mavenCentral()<br> maven { url 'https://jitpack.io' }<br> }<br>}<br>
If the issue persists, please provide the specific error message or log output for further troubleshooting.
 

Latest posts

P
Replies
0
Views
1
Paras Chouhan
P
Top