upgrade-support icon indicating copy to clipboard operation
upgrade-support copied to clipboard

React Native - Gradle build issues after upgrading to version 0.80.2 from 0.73.6, compileSdkVersion update from 34 to 35

Open sowjanyakundeti-stack opened this issue 5 months ago • 2 comments

Trying to update packages for my react-native cli app.

I am facing the following issues when i run ./gradlew clean command after i have upgraded all packages including react-native, react and gradle.

I have been upgrading my compileSdkVersion to 35 which was previously 34 after play store's notification.

Image

Here's the build output and relevant file details.

Image

Any help would be appreciated. Thanks in advance!

1: Task failed with an exception.
Where: Build file '/Users/sowjanya.kundeti/Documents/fareye-app/FashionEyeApp/android/app/build.gradle' line: 7

What went wrong: A problem occurred evaluating project ':app'.

Could not read script '/Users/sowjanya.kundeti/Documents/fareye-app/FashionEyeApp/node_modules/react-native/scripts/react_native_gradle_plugin.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

android/build.gradle file

buildscript {
    ext {
        compileSdkVersion = 35
        buildToolsVersion = "35.0.0"
        minSdkVersion = 24
        targetSdkVersion = 35
        ndkVersion = "25.1.8937393"
        kotlinVersion = "2.1.20"
        reactNativeGradlePluginVersion = "0.80.2"
    }
    repositories {
        google()
        mavenCentral()
        maven { url("$rootDir/../node_modules/react-native/android") }
    }
    dependencies {
        classpath("com.android.tools.build:gradle:8.4.0")
        classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion")
        classpath("com.google.firebase:firebase-crashlytics-gradle:3.0.1")
        classpath("com.google.gms:google-services:4.4.1")
    }
}

package.json

{
    "name": "Fashion Eye",
    "version": "0.0.1",
    "private": true,
    "scripts": {
        "android": "react-native run-android --mode=release",
        "ios": "react-native run-ios",
        "lint": "eslint .",
        "start": "react-native start --reset-cache",
        "test": "jest"
    },
    "dependencies": {
        "@react-native-async-storage/async-storage": "^2.2.0",
        "@react-native-community/checkbox": "^0.5.20",
        "@react-native-community/netinfo": "^11.4.1",
        "@react-native-firebase/analytics": "^22.4.0",
        "@react-native-firebase/app": "^22.4.0",
        "@react-native-firebase/crashlytics": "^22.4.0",
        "@react-native-picker/picker": "^2.11.1",
        "@react-native/new-app-screen": "0.80.2",
        "@react-navigation/native": "^7.1.16",
        "@react-navigation/native-stack": "^7.3.23",
        "@react-navigation/stack": "^7.4.4",
        "@reduxjs/toolkit": "^2.8.2",
        "axios": "^1.11.0",
        "dotenv": "^17.2.1",
        "hermes-engine": "^0.11.0",
        "moment": "^2.30.1",
        "package": "^1.0.1",
        "react": "19.1.0",
        "react-lazyload": "^3.2.1",
        "react-native": "0.80.2",
        "react-native-device-info": "^14.0.4",
        "react-native-dotenv": "^3.4.11",
        "react-native-elements": "^3.4.3",
        "react-native-exit-app": "^2.0.0",
        "react-native-fast-image": "^8.6.3",
        "react-native-fs": "^2.20.0",
        "react-native-image-colors": "^2.5.0",
        "react-native-image-picker": "^8.2.1",
        "react-native-otp-entry": "^1.8.5",
        "react-native-permissions": "^5.4.2",
        "react-native-safe-area-context": "^5.5.2",
        "react-native-screens": "^4.13.1",
        "react-native-slick": "^1.6.0",
        "react-native-snap-carousel": "^1.3.1",
        "react-native-svg": "^15.12.0",
        "react-native-toast-notifications": "^3.4.0",
        "react-native-version-check": "^3.5.0",
        "react-redux": "^9.2.0",
        "redux": "^5.0.1",
        "redux-saga": "^1.3.0",
        "rn-range-slider": "^2.2.2"
    },
    "devDependencies": {
        "@babel/core": "^7.25.2",
        "@babel/preset-env": "^7.25.3",
        "@babel/runtime": "^7.25.0",
        "@react-native-community/cli": "19.1.1",
        "@react-native-community/cli-platform-android": "19.1.1",
        "@react-native-community/cli-platform-ios": "19.1.1",
        "@react-native/babel-preset": "0.80.2",
        "@react-native/eslint-config": "0.80.2",
        "@react-native/gradle-plugin": "^0.80.2",
        "@react-native/metro-config": "0.80.2",
        "@react-native/typescript-config": "0.80.2",
        "@types/jest": "^29.5.13",
        "@types/react": "^19.1.0",
        "@types/react-test-renderer": "^19.1.0",
        "babel-jest": "^29.5.13",
        "eslint": "^9.32.0",
        "prettier": "3.6.2",
        "react-native-clean-project": "^4.0.3",
        "react-native-svg-transformer": "^1.5.1",
        "react-test-renderer": "19.1.0",
        "typescript": "5.8.3"
    },
    "engines": {
        "node": ">=18"
    }
}

android/app/build.gradle

plugins {
    id 'com.android.application'
    id 'org.jetbrains.kotlin.android'
    id 'com.google.firebase.crashlytics'
    id 'com.google.gms.google-services'
}
apply from: "../../node_modules/react-             
native/scripts/react_native_gradle_plugin.gradle"

android {
    compileSdkVersion rootProject.ext.compileSdkVersion
    buildToolsVersion rootProject.ext.buildToolsVersion
    ndkVersion rootProject.ext.ndkVersion

    namespace "com.fashioneyeapp"
    defaultConfig {
        applicationId "com.fashioneyeapp"
        minSdkVersion rootProject.ext.minSdkVersion
        targetSdkVersion rootProject.ext.targetSdkVersion
        versionCode 16
        versionName "1.10"
    }

    signingConfigs {
        debug {
            // ...
        }
        release {
            // ...
        }
    }

    buildTypes {
        debug {
            signingConfig signingConfigs.debug
        }
        release {
            shrinkResources true
            signingConfig signingConfigs.release
            minifyEnabled false
            proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
        }
    }
}

dependencies {
    implementation platform('com.google.firebase:firebase-bom:33.1.2')
    implementation("com.facebook.react:react-android")
    implementation 'com.google.firebase:firebase-analytics'
    implementation 'com.google.firebase:firebase-crashlytics'
    if (hermesEnabled.toBoolean()) {
        implementation("com.facebook.react:hermes-android")
    } else {
        implementation 'io.github.react-native-community:jsc-android:2026004.+'
    }
}

Settings.gradle

pluginManagement {
    repositories {
        maven { url("$rootDir/../node_modules/react-native/android") }
        gradlePluginPortal()
        google()
        mavenCentral()
    }
}

dependencyResolutionManagement {
    repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
    repositories {
    maven { url("$rootDir/../node_modules/react-native/android") }
        google()
        mavenCentral()
    }
}

rootProject.name = "FashionEyeApp"
include(":app")

gradle-wrapper.properties

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

I have tried clearing cache, deleting node modules, re-building. Still it doesn't work.

sowjanyakundeti-stack avatar Aug 07 '25 06:08 sowjanyakundeti-stack

Delete your .gradle folder from destination and rebuild, /Users/hlx/.gradle (in case of mackbook user file path)

Note: In some cases, react-native-screen version also effect.

zahid502 avatar Aug 08 '25 19:08 zahid502

in your android/app/build.gradle

replace this :

plugins {
    id 'com.android.application'
    id 'org.jetbrains.kotlin.android'
    id 'com.google.firebase.crashlytics'
    id 'com.google.gms.google-services'
}
apply from: "../../node_modules/react-             
native/scripts/react_native_gradle_plugin.gradle"

with this :

apply plugin: "com.android.application"
apply plugin: "org.jetbrains.kotlin.android"
apply plugin: "com.google.firebase.crashlytics"
apply plugin: "com.facebook.react"

M-Samad avatar Aug 29 '25 23:08 M-Samad