I could not figure out the reason for this same error, I've changed my JDK from jdk 8, 11, 17, and 20 still the error was not resolved. Deleted my android/ folder still I did not solve. I think mine is a bit different from others whi had this same error.
This is the error i have been having: *Could not open settings generic class cache for settings file 'C:\Users\Benj\projects\TikTokClone\android\settings.gradle' (C:\Users\Benj.gradle\caches\7.5\scripts\e34934ll5fugwo6b0s7f5a19r).
BUG! exception in phase 'semantic analysis' in source unit 'BuildScript' Unsupported class file major version 64*
Here is my android/build.gradle:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext {
buildToolsVersion = "31.0.0"
minSdkVersion = 21
compileSdkVersion = 31
targetSdkVersion = 31
}
repositories {
google()
jcenter()
}
dependencies {
classpath("com.android.tools.build:gradle:7.0.3")
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
mavenLocal()
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url("$rootDir/../node_modules/react-native/android")
}
maven {
// Android JSC is installed from npm
url("$rootDir/../node_modules/jsc-android/dist")
}
google()
jcenter()
maven { url 'https://www.jitpack.io' }
}
}
This is my android/gradle/wrapper/gradle-wrapper.properties
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
My android/setting.gradle
rootProject.name = 'TikTok'
apply from: file("../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesSettingsGradle(settings)
include ':app'
The error means that you try to run a Gradle 7.5 build with Java 20.
As you can see at https://docs.gradle.org/current/userguide/compatibility.html this is not supported, but only up to Java 18.
Whatever you select as project JDK in your IDE is pointless unless you configured your IDE to use your project JDK to run Gradle. Typically, it will use JAVA_HOME
by default instead.
Make sure you run Gradle with a compatible Java version, then the error goes away.