Build Fails After Upgrading React Native from 0.67.3 to 0.75.4 - Gradle and SDK Issues

I recently updated my React Native project from version 0.67.3 to 0.75.4, following the instructions provided by the React Native upgrade helper. After running npm install, everything worked as expected. However, when I attempted to build the project using Gradle with the following commands:

./gradlew clear
./gradlew build

I encountered the following errors during the ./gradlew clear command:

FAILURE: Build completed with 2 failures.

1: Task failed with an exception.
-----------
* Where:
Build file 'MyProject/android/app/build.gradle' line: 84

* What went wrong:
A problem occurred evaluating project ':app'.
> Could not read script 'MyProject/node_modules/react-native/react.gradle' as it does not exist.

2: Task failed with an exception.
-----------
* What went wrong:
A problem occurred configuring project ':app'.
> com.android.builder.errors.EvalIssueException: compileSdkVersion is not specified. Please add it to build.gradle

Here’s my android/build.gradle configuration:

buildscript {
    ext {
        kotlinVersion = "1.6.20"
        buildToolsVersion = "33.0.3"
        minSdkVersion = 21
        compileSdkVersion = 33
        targetSdkVersion = 34
        ndkVersion = "21.4.7075529"
    }
    repositories {
        google()
        mavenCentral()
    }
    dependencies {
        classpath('com.android.tools.build:gradle:7.3.0')
        classpath 'com.google.gms:google-services:4.3.15'
    }
}

allprojects {
    repositories {
        maven {
            url("$rootDir/../node_modules/react-native/android")
        }
        maven {
            url("$rootDir/../node_modules/jsc-android/dist")
        }
        mavenCentral {
            content {
                excludeGroup "com.facebook.react"
            }
        }
        google()
        jcenter()
        maven { url 'https://www.jitpack.io' }
        exclusiveContent {
           filter {
               includeGroup "com.facebook.react"
           }
           forRepository {
               maven {
                   url "$rootDir/../node_modules/react-native/android"
               }
           }
       }
    }
}

My gradle-wrapper.properties file:

distributionBase=GRADLE_USER_HOME
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-all.zip
distributionPath=wrapper/dists
zipStorePath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME

Issues:

  1. Missing react.gradle file: It seems like the react.gradle file is missing from node_modules/react-native.
  2. SDK version not recognized: Even though I’ve set compileSdkVersion = 33 in my build.gradle file, the error suggests that it’s not specified.

Questions:

  • Do I need to update the Gradle version, Kotlin version, or SDK versions (buildToolsVersion, minSdkVersion, compileSdkVersion, targetSdkVersion, ndkVersion) to fix these issues?
  • How do I resolve the missing react.gradle file?
  • Is there any additional configuration required after upgrading React Native to version 0.75.4?

I’m fairly new to React Native and would appreciate any help or guidance!

It seems like the react.gradle file is missing from node_modules/react-native .

Maybe you missed some upgrade step you should have taken?
You probably should ask R/N maintainers or community, not Gradle community.

Even though I’ve set compileSdkVersion = 33 in my build.gradle file, the error suggests that it’s not specified.

You set a (bad practice) ext property with that name.
But the Android Gradle Plugin complains that you do not configure that property in its extension, those are two completely separate things.

Do I need to update the Gradle version, Kotlin version, or SDK versions to fix these issues?
How do I resolve the missing react.gradle file?
Is there any additional configuration required after upgrading React Native to version 0.75.4?

You should really ask R/N people how to properly use R/N, this is not too much Gradle related.