3

Here is the error:

FAILURE: Build failed with an exception.

  • What went wrong: Could not open settings generic class cache for settings file 'E:\proj\android\settings.gradle' (C:\Users\patel.gradle\caches\6.7\scripts\1fnwrr8g4rohfp291nvlxj5qe).

BUG! exception in phase 'semantic analysis' in source unit 'BuildScript' Unsupported class file major version 60

  • Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

  • Get more help at https://help.gradle.org

BUILD FAILED in 2s Exception: Gradle task assembleDebug failed with exit code 1


I already change JDK 16 to 8 and update Gradle version.

Muhammad Zahab
  • 1,049
  • 10
  • 21
Rutvik patel
  • 31
  • 1
  • 1
  • 3

7 Answers7

12

I added this line to ./android/gradle.properties for OSX org.gradle.java.home=/Applications/Android Studio.app/Contents/jre/Contents/Home Android Studio changed their file path for the jre so I think this will go away once flutter fixes with a new version

j3g
  • 396
  • 2
  • 10
  • 1
    Worked for me. Thanks. The originally answer gets the upvote :) – Jonny Right Aug 19 '21 at 16:49
  • 4
    not worked for me. I got this error ```Value '/Applications/Android Studio.app/Contents/jre/Contents/Home' given for org.gradle.java.home Gradle property is invalid (Java home supplied is invalid)``` – Tony Lucas Sep 08 '21 at 03:54
  • Works! Upvoted :-) But what is behind this problem? Why did it happen? – Constantine Kurbatov Sep 20 '21 at 17:53
  • Problem solved! Thanks – Eaglechrome Nov 03 '21 at 16:29
  • Change to 'org.gradle.java.home=/Applications/Android Studio.app/Contents/jbr/Contents/Home' worked. Just change **jre** in the original answer to **jbr**. Upvoted and thanks! Android Studio version: Electric Eel | 2022.1.1 – Chandler Feb 02 '23 at 00:31
  • What is ./android/gradle ? Where do I find it? I have .android and .gradle in my user folder but what they don't have gradle.properites. – user541396 Apr 01 '23 at 18:19
6

In gradle.properties, try to add that org.gradle.java.home=C:\\Program Files\\Android\\Android Studio\\jre

Flamageil
  • 110
  • 1
  • 10
  • You can also check that : https://stackoverflow.com/questions/59647791/tag-android-studio-not-installed-when-run-flutter-doctor-while-android – Flamageil Jun 21 '21 at 14:05
3

To resolve this issue you have to follow these steps, they worked for me:

  1. Go to your gradle-wrapper.properties file and change the gradle plug-in version to the latest. e.g distributionUrl=https://services.gradle.org/distributions/gradle-7.2-bin.zip

It means 7.2 is the latest as at the time of writing this.

NOTE: Open your flutter app: android>gradle>wrapper>gradle-wrapper.properties

  1. Then, open your app and go to: android>build.gradle

open the file and in the buildScript and under the dependencies block, give a compactible version to the Gradle.

An example is shown below.

buildscript {
  ext.kotlin_version = '1.6.21'
  repositories {
      google()
      mavenCentral()
  }

  dependencies {
      classpath 'com.android.tools.build:gradle:7.1.3'
  }
}
  1. In your manifest file: android>app>src>main>androidManifest.xml

open it and under the activity tag, add: android:exported="true"

You can then invalidate caches and rebuild your project. try it and give me feedback.

Reference is from the official doc

https://developer.android.com/studio/releases/gradle-plugin

2

I added this line to ./android/gradle.properties for OSX:

org.gradle.java.home=/Applications/Android Studio.app/Contents/jre/Contents/Home

This is what worked for me.

Ole Pannier
  • 3,208
  • 9
  • 22
  • 33
  • 3
    you literally copied my answer instead of giving me an upvote with a comment of "this is what worked for me". (look at the timestamps) – j3g Aug 19 '21 at 06:03
1

This happens, because gradle and Java versions are incompatible. For my case, it was about JDK in gradle settings. All of the answers above didn't help me. I've solved by myself.

What I did:

  1. I opened the project structure (File -> Project Structure) in Android Studio, navigated to the "SDK Location" tab and then clicked to "Gradle Settings":

enter image description here

  1. In gradle settings, I changed the gradle JDK's version to the compatible one:

enter image description here

for example, in the image above, I'm using gradle 6.7.1 and JDK 15.0.2 - which are compatible.

Make sure your gradle and Java versions are compatible. You can check the compatibility table here: https://docs.gradle.org/current/userguide/compatibility.html

0

How I resolve the issue on my macOS 1, run; flutter doctor 2, run; sudo gem install cocoapods. After the lengthy installation, I run again, flutter doctor. and it was SOLVED.

For more info, see https://flutter.dev/platform-plugins

To install see https://guides.cocoapods.org/using/gettingstarted.html#installation for instructions.

0

In gradle wrapper.properties, change the code to this -

distribution Url = https://services.gradle.org/distributions/gradle-7.2-all.zip

In build.gradle, change the code to this -

classpath "com.android.tools.build:gradle:7.1.3"