skip to Main Content

I am having this issue on mac
enter image description here

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
enter image description here

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
enter image description here

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
enter image description here

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

3

Answers


  1. Chosen as BEST ANSWER

    After Trying for weeks what later worked for me was going to Project_File>Android>build.gradle file and changing

    dependencies {
            classpath 'com.android.tools.build:gradle:7.1.3'
            classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        }
    

    To:

    ...
    classpath 'com.android.tools.build:gradle:4.1.3'
    ...
    

    and i just run ./gradlew clean build and then run the project, everything now working fine

    Thanks All


  2. search for gradle in preferences and then select the correct Gradle JDK

    enter image description here

    Login or Signup to reply.
  3. 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
        }
    }
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search