i am facing the following error while building my flutter app in gradle project file
Could not open cp_init generic class cache for initialization script
‘/Users/ahmedelsayed/Library/Application
Support/Code/User/workspaceStorage/019afb36a6af79f79236dde7350a9026/Oracle.oracle-java/userdir/var/cache/gradle/nb-tooling.gradle’
(/Users/ahmedelsayed/.gradle/caches/7.6.3/scripts/4dpa3vsev7uot0q71zkfh79r1).
BUG! exception in phase ‘semantic analysis’ in source unit
‘BuildScript‘ Unsupported class file major version 66(errors:1)
i tried all the solutions proposed here but non worked,
i tried to change gradle jdk to 1.8 and 11 and it didnot work
removed cashe folder 4dpa3vsev7uot0q71zkfh79r1and also did not work
also tried to invalidate cashe but no change
when i run the project on VSCode i get the following error
Execution failed for task ‘:location:compileDebugKotlin’.
A failure occurred while executing org.jetbrains.kotlin.compilerRunner.GradleCompilerRunnerWithWorkers$GradleKotlinCompilerWorkAction
┌─ Flutter Fix
──────────────────────────────────────────────────────────────────────────────┐
│ [!] Your project requires a newer version of the Kotlin Gradle
plugin. │ │ Find the latest version on
https://kotlinlang.org/docs/releases.html#release-details, then │ │
update
/Users/ahmedelsayed/Downloads/FreeLance/MobileApps/sayarah/android/build.gradle:
│ │ ext.kotlin_version = ”
and that what happen when changing kotlin version
Could not resolve all files for configuration ‘:classpath’.
Could not find org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.1.
Searched in the following locations:
– https://dl.google.com/dl/android/maven2/org/jetbrains/kotlin/kotlin-gradle-plugin/1.7.1/kotlin-gradle-plugin-1.7.1.pom
– https://jcenter.bintray.com/org/jetbrains/kotlin/kotlin-gradle-plugin/1.7.1/kotlin-gradle-plugin-1.7.1.pom
my project build gradle
buildscript {
ext.kotlin_version = '1.8.0' // Change here
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:7.4.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
allprojects {
repositories {
google()
mavenCentral()
}
}
rootProject.buildDir = '../build'
subprojects {
project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
project.evaluationDependsOn(':app')
}
tasks.register("clean", Delete) {
delete rootProject.buildDir
}
my app build gradle
plugins {
id "com.android.application"
// START: FlutterFire Configuration
id 'com.google.gms.google-services'
// END: FlutterFire Configuration
id "kotlin-android"
id "dev.flutter.flutter-gradle-plugin"
}
def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
localPropertiesFile.withReader('UTF-8') { reader ->
localProperties.load(reader)
}
}
def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
flutterVersionCode = '1'
}
def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {
flutterVersionName = '1.0'
}
android {
namespace "com.example.sayarah"
compileSdk 34
ndkVersion flutter.ndkVersion
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
}
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.example.sayarah"
minSdk 28
targetSdk 34
versionCode flutterVersionCode.toInteger()
// You can update the following values to match your application needs.
// For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration.
versionName kotlin_version
}
buildTypes {
release {
// TODO: Add your own signing config for the release build.
// Signing with the debug keys for now, so `flutter run --release` works.
signingConfig signingConfigs.debug
}
}
buildToolsVersion '34.0.0'
}
flutter {
source '../..'
}
dependencies {}