I am developing with flutter on visual studio code. recently I upgraded gradle to 7.0.2, and changed this section in build.gradle file accordingly:
dependencies {
classpath 'com.android.tools.build:gradle:7.0.2'. <--- here
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.google.gms:google-services:4.3.5'
classpath 'com.google.firebase:firebase-crashlytics-gradle:2.5.2'
}
than I run flutter (flutter run) and got this error:
so I upgraded java to 11 and made sure it applied with the next command: gradlew --version:
so supposingly, all should work, but the error above keep showing, even after restarting visual studio code - does anyone have an idea what could be missing or went wrong ?
btw: there are other posts explaining how to fix this issue with android studio, but non for visual studio code. thanks!
CodePudding user response:
Most appropriate solution I think would be to spacify the org.gradle.java.home
variable in gradle.properties file. Do it like this:
org.gradle.java.home=Path_to_jdk
Make sure not to put any quotation marks before and after the path.
CodePudding user response:
In build.gradle
, set
sourceCompatibility = '11'
targetCompatibility = '11'
After it's rebuilt successfully,clean java language server workspace
from Command Palette then reload window. See if the question goes away.