0

I am restarting my Android development journey after 9 years, but when I try building my first project on Android Studio v2022.2.1, I encounter this error:

Unsupported Java. 
Your build is currently configured to use Java 20.0.1 and Gradle 8.0.

Possible solution:
 - Open Gradle wrapper settings, change `distributionUrl` property to use compatible Gradle version and reload the project

I searched for solutions on Stack Overflow and noticed that it's primarily related to Gradle properties and version issues, and most of the solutions recommended to either upgrade the Gradle version to 7.4+ or downgrade the JDK version.

But, I am already using Gradle v8.0 and latest JDK, available for my OS (Windows 10 OS x64 architecture). So, what could be the issue.

I have already attempted the following steps listed in these 2 Stack Overflow answers:

But the issue persists.

Mark Rotteveel
  • 100,966
  • 191
  • 140
  • 197
Manu Mathur
  • 113
  • 1
  • 7
  • 1
    Have you tried **downgrading** to Gradle 7.6 and maybe to Java 17 (or even Java 11)? Though given the error, more likely you only need to downgrade Java. – Mark Rotteveel Jun 01 '23 at 08:02
  • Let me try this method, Mark. To achieve the same, I shall - 1) Uninstall the current JDK v20 from the system and will reinstall JDK v17. Will also reset the environment and system variables. Hope that works. – Manu Mathur Jun 01 '23 at 08:59
  • Hey @MarkRotteveel - the issue stands resolved. AS is no longer throwing error and the build is successful. Thanks for reminding me to downgrade the JDK version. – Manu Mathur Jun 01 '23 at 09:49

1 Answers1

1

In the Project Structure menu -> SDK Location -> Gradle settings, set Gradle JDK to embedded JSD 17.0.6

mostafa3dmax
  • 997
  • 7
  • 18
  • Thank you, @mostafa for this suggestion, but I had already given this a try, but didn't succeed. What worked in my favor is - downgrading the JDK version from 20 to 17. – Manu Mathur Jun 01 '23 at 09:52