Everything was working fine untill i tried to run a flutter code i bought from Codecanyon and started having this issue, which i tried so many fix which i saw online and will list them bellow, but now even the new flutter projects i create now give same issue
Steps: i have installed java 11 and 16 as well
then tried to change the defaul jdk version using
export JAVA_HOME=`/usr/libexec/java_home -v 11.0.17`
and
export JAVA_HOME=$(/usr/libexec/java_home -v 11)
then when i run java -version
on the terminal i get the report bellow
which i believe means i have succefuly changed it (I haved tried using bash, switched to Zsh and now back to bash) but it's still not working
Also tried to change it via the IDE from some solutions i saw here on stackOverflow but from the android-studio> Prefrences> Build, Execution, Deployment> Gradle the section is not showing until i try the File> Project Structure> Project and select JDK 11
Still not working, even installed the latest version of Android Studio, still didn't fix the issue, and i had to install the old version again since my emulator stopped working after the update
Have been battling this for some weeks to a month now, have checked multiple solutions here and on github but still can't get a solution that works
CodePudding user response:
search for gradle
in preferences and then select the correct Gradle JDK
CodePudding user response:
The current flutter version does not support this project. You can open the Gradle configuration file embedded in the current flutter version to view the Gradle information.
open android>app>build.gradle line 24
- apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
- open terminal run "whereis flutter" you can get flutter install path
- open "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" file
You will see the gradle version used by the current flutter version and current java compile version
buildscript {
repositories {
google()
mavenCentral()
}
dependencies {
/* When bumping, also update ndkVersion above. */
classpath 'com.android.tools.build:gradle:4.1.0'
}
}
android {
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}