skip to Main Content

It’s my first time building an app, and I am doing it on Flutter. However, my build.gradle has an error and when i hover my mouse over it, this is what I get.

Could not run phased build action using connection to Gradle distribution ‘https://services.gradle.org/distributions/gradle-7.6.3-all.zip’.
org.gradle.api.ProjectConfigurationException: A problem occurred configuring root project ‘android’.
A problem occurred configuring root project ‘android’.
A problem occurred evaluating root project ‘android’.
A problem occurred configuring project ‘:app’.
Build file ‘/Users/shermanchew/Documents/GitHub/WheresTheHalal/wheres_the_halal/android/app/build.gradle’ line: 2
An exception occurred applying plugin request [id: ‘com.android.application’] Failed to apply plugin ‘com.android.internal.application’.
Android Gradle plugin requires Java 11 to run. You are currently using Java 1.8.
Your current JDK is located in /Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home
You can try some of the following options:

  • changing the IDE settings.
  • changing the JAVA_HOME environment variable.
  • changing org.gradle.java.home in gradle.properties.

I tried to play around with the recommendations and installed java 11. My JAVA_HOME is pointing to the correct JDK and have added the line "org.gradle.java.home=$(/usr/libexec/java_home -v 11)" to my gradle.properties. I’m not sure how else I can resolve this problem.

2

Answers


  1. Run java -version in your terminal to check your Java Development Kit version. if the version is still 1.8, which is what your project is complaining about, chances are you did not define the path correctly to your JDK in your shell file.

    Try adding these two lines to your shell file:

    export JAVA_HOME=/path/to/your/jdk11
    
    export PATH=$JAVA_HOME/bin:$PATH
    

    remember to replace /path/to/your/jdk11 with the correct path to your JDK.
    save and close your shell and run the
    source ~/.bash_profile command in your terminal to apply the changes.

    then simply run these commands in your project’s root flutter clean and flutter pub get.

    this will solve your issue I believe.

    Login or Signup to reply.
  2. Hi I had this same issue and took several days to try and fix it and I finally solved it, you need to download the latest version of Java at oracle.com and I downloaded the Java 17 version, after you download it you need to update it into your environment variables and set the path to where it is located, also you need to upgrade this on your build.gradle file and put 17 for the versions, hope this helps

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search