Search code examples
javascriptandroidreactjsreact-nativegradle

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


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

// 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


Solution

  • Resolved:

    For some reason my PC decided to change my version overnight of gradle in gradle-wrapper.properties from 8.6 to 8.3

    gradle-wrapper.properties

    distributionBase=GRADLE_USER_HOME
    distributionPath=wrapper/dists
    distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-all.zip
    networkTimeout=10000
    validateDistributionUrl=true
    zipStoreBase=GRADLE_USER_HOME
    zipStorePath=wrapper/dists
    

    Changed it to version 8.6 and now it passes by the build