I have installed Android Studio Canary 2020.3.1.22
and trying to run Flutter
project on Apple Silicon(ARM) Mac
. Unfortunately, it is giving me this error when I try to run default
flutter counter app.
Here is the error I am getting:
Could not open settings generic class cache for settings file '/Users/khamidjonkhamidov/StudioProjects/dummy/android/settings.gradle' (/Users/khamidjonkhamidov/.gradle/caches/6.7/scripts/f0emg6u6oecmxqzgk5g9nn4ui).
> BUG! exception in phase 'semantic analysis' in source unit '_BuildScript_' Unsupported class file major version 61
Gradle version: 6.7
but I tried 7+
JDK version 17
I would really appreciate your help)
28
Answers
Basically, I installed jdk using
brew install java
which was not compatible with my current gradle I guess. Sobrew uninstall java
JDK 8 or JDK 11
from azul.When done, everything worked smoothly.
According to the official grade docs: Java 17 and later versions are not yet supported.
You can check compatibility here.
So I have installed
Java11
from Azul.p.s. don’t forget to change jdk version in Android studio
Preferences -> Build -> Build Tools -> Gradle -> Gradle JDK
First, you can execute this command:
/usr/libexec/java_home -V
, to retrieve all installed jdsk:Now, imagine you want to remove the version 17:
Go into the path of the version you want to remove (in this case "/Users/ciccio/Library/Java/JavaVirtualMachines/openjdk-17.0/Contents/Home"), and delete entire folder: "/Users/ciccio/Library/Java/JavaVirtualMachines/openjdk-17.0".
Once removed, go back on terminal and use:
to force the new version to use (14.0.1).
Next check if is correct:
Your Gradle now is back to work.
I found a way to fix this error without messing with the locally installed Java version or Gradle. Here is what I did:
Tested on MacBook Air M1 running macOS Monterey 12.2.1.
Got the same error while I upgraded my build.gradle to Java 17. And the fix is as simple as we think:
Here’s the complete reference for Java vs Gradle compatibility:
https://docs.gradle.org/current/userguide/compatibility.html
Upgraded my gradle to 7.3 in gradle-wrapper.properties.
Some of you may experience now the Gradle dependency cache corrupt error after this like me. So better delete the gradle-wrapper.jar and reinstall it using the command:
Everything will work perfectly fine from here.
In case if you still face Gradle corrupt issue, please check whether you are using latest version of IDE especially Intellij.
I had this issue when I set the target for a new IntelliJ Kotlin project to be Java 17. My fix was to:
build.gradle.kt
.gradle
and.idea
directories from the project folderOpen the Gradle settings and change the Gradle JVM to the same JDK version you are using.
(I am using 14.0.2)
This worked for me.
I had that Issue creating Projects from IntelliJ.
It seems the issue was the Gradle JVM Version.
Here is a configuration that works:
System:
Mac with ARM, Mac OS 12.1, M1 Max
I installed those version with sdkman https://sdkman.io/
and set the config manually on intellij (See attached Screenshot for Details)
IntelliJ Gradle JVM config
My solution was to open the android project in Android Studio. It detected the needed Gradle update and performed the update upon command.
Check currently active java version:-
If it is greater than 11 downgrade it to 11 or 8. Check your available java jdk version installed:-
If java 11 or 8 is not installed first install one of them using this link:- Download jdk 8
then change the default java version in .bash_profile
Edit .bash_profile
Add 1.8 or 11 as default. (Add below line to bash_profile file)
OR
Now Press CTRL+X to exit the bash. Press ‘Y’ to save changes. And reload bash_profile
I can’t speak for everyone, but for me, I went into Flutter project’s file
android/gradle/gradle.properties
, and changed theorg.gradle.java.home
value so that it pointed to a folder containing JDK 11 instead of JDK 18. That way, it used a JDK version that was actually supported.Giving my two seconds here…
In my case, I could fix it by finding my gradle version in the file gradle.wrapper.properties and checking the compatibility with the JDK, so I needed to install the JDK 16, so in my build.gradle(:app) I put this line of code inside the android {} :
After this I build my android version again, and it worked.
On my side I fixed this issue by setting the default
Java Version
to8
(download it if needed)Mac:
open ~/.bash_profile
I ran into this issue on VSCode+Mac using the Gradle for Java extension.
My project uses Java 17 but Gradle was using JDK19, which I also had installed.
I removed the
jdk-19.jdk
folder from/Library/Java/JavaVirtualMachines
and then ran the "Clean Java Language Server Workspace" task in VSCode.After that, Gradle successfully built and I was even able to put the jdk-19 folder back and things continued to work.
Changing the Java Version in the Intellij resolved the issue.
I faced this error when I updated my android studio
Solution:
you need to upgrade your
distributionUrl
According to thejava version
Below is the
Java version
and SupportedGradle version
Easy fix in 2023:
Command in the terminal:
export JAVA_HOME=$(/usr/libexec/java_home -v 1.8)
Check classpath, current working one:
classpath ‘com.android.tools.build:gradle:7.1.2’
Check gradle-wrapper.properities file:
If still not solved you need to change Gradle JDK from inside Android Studio like below.
After that you can run fluter app directly from terminal without any issue. Note: Android Studio default JDK (11.0.15) does not work and causes this issue. Azul Zulu 16.0.2 works and solves the issue.
In my case, I use the react native cli and my android gradle is 7.3.1. I open the android folder in the android folder in the android studio and it suggests my gradle once after degradation it works fine
Windows Users
Open Android Studio and Click on Setting ICON far right. And Go to Project Structure Option and select the SDK’s Version 11.0.15 and click apply than on the left side click on Module Option and select Module SDK’s options and select Project SDK 11. and at the bottom at Project Settings CLICK on SDK and select on 11 SDK versions. It will give you the JDK path
C:Program FilesAndroidAndroid Studiojbr
Copy this path and Open the System Environment Variable Create a New
JAVA_HOME
path with the locationand click OK and save everything Now run your app in ANDROID STUDIO and ENJOY!
Happened with newly created Flutter app in 2023 January with Mac Mini M1. If you have another working Flutter apps do not downgrade or update Java version as it will cause problem with all other working ones. Find gradle-wrapper.properities file inside
gradle/wrapper
folder (directly inside Android folder) and check gradle version. You just need to use newer version of gradle. I replaced this one and usedflutter run
command from terminal and it worked:With this one:
No need to do anything else. Version number may be different for you depending on when you are trying this and what Java version you have.
Note: Same fix also effective for another error message as well stating version 63:
Context: Flutter, Mac M1, Java 19.0.2
Problem occured on following command:
I just installed (reintalled) gradle via homebrew like this:
I suppose it was related to my recent upgrade (Java was upgraded to OpenJDK Temurin 19.0.2).
I also noticed that flutter command was trying to use gradle 7.4 (the only one gradle version installed before). As previously mentioned by others, there has to be consistency between your Java version and gradle version according to Gradle Official Compatibility Matrix.
Please, verify it with following commands:
I think this process / solution can be applicable in general. Hope it helps!
System: Mac M1, Android Studio Electric Eel (2022.1.1 Patch 1), JDK 19.02
I encountered this error when created a fresh project using
flutter create
and tried to run it in Android Studio.Now I’ve got an interesting solution that worked for me:
Finally I Got the Solution
It is very easy to solve
step 1 : select the gradle version which support your java version link
step 2 : open your project navigate to your_project_name/android/gradle/wrapper/gradle-wrapper.properties
step 3 : in distributionUrl change the gradle version according to your java version
That’s it No need to install older java versions
Happy coding
This problem can be solve by cleaning and upgrading the flutter project
use these command on your terminal
–> flutter clean
then run
–> flutter upgrade
SOLUTION:
go to android/gradle/wrapper/gradle-wrapper.properties
Find the distributionUrl variable and change the end path to gradle-7.6-all.zip
Error
Steps To Solve :
1- open the gradle prodperties see the current project gradle example "gradle-7.4"
2- open compatibility see https://docs.gradle.org/current/userguide/compatibility.html
3- download java version, in ower example java 17
https://www.oracle.com/java/technologies/downloads/
Usually, this bug relates to the incompatibility of the gradle version and the JDK version.
if you want to be sure. first check this for compatibility.
if this is your problem. find your version in this, then rename your version in
gradle-wrapper.properties
of your project.In my case I had this set
Typing
flutter --version
on terminal:Typing
javac -version
on terminal to get you java version:So, by this grade compatibility matrix I had to update my
project/android/gradle/wrapper/gradle-wrapper.properties
distributionUrl to: