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
ingradle.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
Run
java -version
in your terminal to check your Java Development Kit version. if the version is still1.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:
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
andflutter pub get
.this will solve your issue I believe.
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