47

I reinstalled my android studio since the sdk was not found and so on. After re installing java jdk and android studio , everything worked well until I got an error saying 'Could not initialize class org.codehaus.groovy.runtime.InvokerHelper' which I solved by changing the Gradle version. And now the error is 'Type 'FlutterTask' property 'assets' is missing an input or output annotation.'

FAILURE: Build failed with an exception.

  • What went wrong: Could not open settings generic class cache for settings file 'C:\Users\loran\ASProjects\xylophone-flutter\android\settings.gradle' (C:\Users\loran.gradle\caches\6.8.2\scripts\4mawlyb2l5e9tefyvnpxva1kg).

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 46s Exception: Gradle task assembleDebug failed with exit code 1

lorandsouza
  • 471
  • 1
  • 4
  • 3

26 Answers26

29

I also had this problem So I did install java 8 You might have Java 13 So install Java 8

Vishal Adhithya
  • 407
  • 3
  • 4
24

Java JDK 16 is the one that seems to lead to this issue try downgrading by downloading a lower version of JDK preferable JDK 8 or 11

To future individuals who will run to this error. Here is the link to download the JDK enjoy your coding experience don't forget to change the path too. https://www.oracle.com/java/technologies/javase-downloads.html

13Tracso
  • 479
  • 4
  • 8
7

FOUND IT ! No need to change your JDK version, follow the steps to resolve the issue:

  • check your java version and remember it, use "java -version" in terminal
  • go to your android studio path installation
  • then in: Android Studio/jre/ open the file named "release"
  • take attention of the value of JAVA_VERSION field
  • if it's not the same as the java version on your computer, just change it with the version installed on your computer.

That's it, i hope it will resolve your issue like it resolves mine.

Try it and give a feedback.

Tafita Raza
  • 206
  • 2
  • 4
7

You can try this, It works for me.

Open the Android module to a new window and automatically download all necessary libraries after successfully building finished run the app.

enter image description here

Yousuf Ali
  • 159
  • 2
  • 5
6

Try installing the latest Gradle package gradle-7.1.1, if you are using Java JDK 16 installed. To do this open android/gradle/wrapper/gradle-wrapper.properties file and under distribution url, update the gradle version to 7.1.1 (or the latest). After that, inside your Flutter project directory, run the following command in the terminal:

cd android && ./gradlew
Anmol Tiwari
  • 89
  • 1
  • 3
5

mainly you have jdk16 i tried to install java 8 and set env to java 8 it worked for me

5

I removed the JAVA_HOME path to the JAVA download and changed JAVA_HOME path to the following:

C:\Program Files\Android\Android Studio\jre

I am now coding

5

So the problem arises from inconsistency in the Java version installed on your machine, the default Java version configured on your android studio and the gradle version for your project. So building upon the answer given by Tafita Raza I fixed it following the steps below

  • Check your java version and remember it, use "java -version" in terminal
  • Go to your android studio path installation
  • In newer versions of android studio go to Andriod Studio/jbe while in older versions go to Android Studio/jre/ and edit the file named "release"
  • Replace the value of JAVA_VERSION with the version of Java installed on your machine if it's not the same as the java version on your computer
  • Now go into the project folder you are building and check if the gradle version is compatible with the Java you have installed

Java and gradle compatibility

  • I had java 19.0.2 installed on my system so according to the table I need gradle version 7.6 to build a project. You can also check the official website gradle if your java version is not listed https://docs.gradle.org/current/userguide/compatibility.html
  • Go into your project_name/android/gradle/wrapper and edit the file gradle-wrapper.properties
  • Replace the distributionUrl with the version of gradle compatible with the java version on your system DistributionUrl Example
Bello Tomi
  • 513
  • 6
  • 9
  • 1
    Thank you! The compatibility table you provided was very useful. I had Java 17.0.6 and gradle 4.0.2. I updated gradle to 7.3.0 in my flutter project and now the app runs without problems. – SAM Jun 18 '23 at 23:48
1

Try this! Remove package android from the top of settings.gradle. This helped me out.

Mahdi Bagheri
  • 23
  • 1
  • 9
1

Simply go to your Android Studio path -> C:\Program Files\Android\Android Studio open jbr folder -> copy all files -> then go back -> paste all the files in the jre folder and "replace the files in the destination". It works for me in two different laptops. I have latest jdk version - 19.0.2

1

All you have to do is change the java version to 11 and provide JAVA_HOME to jdk 11. You need to ensure to delete any other java versions (latest). Then restart the system and it will work.

1

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"

And then, hit flutter run in terminal

0

If this error occurs, this might because you have installed the latest JDK such as JDK 16. You download and install JDK 8 and uninstall JDK 16. Then restart the desktop/laptop and try launch and run flutter run again. It should be working fine.

Eric
  • 9
  • 1
0

In my case, on Windows 10, my JAVA_HOME was set to JAVA SE 16 C:\Program Files\Java\jdk-16 and when I looked at the release file in java jre in android studio, C:\Program Files\Android\Android Studio\jre\release, I found that the the JAVA_VERSION WAS "11.0.10" (java 11) for short. So I changed the java installation on my PC to Java 11, update JAVA_HOME in my environment variables to point to the new java (C:\Program Files\Java\jdk-11.0.12) and restarted android studio, Then everything worked.

You can get your java 11 from here. https://www.oracle.com/java/technologies/javase-jdk11-downloads.html. Change 11 to 8, 16 etc to get the download link for the java version you need.

Samuel Nde
  • 2,565
  • 2
  • 23
  • 23
0

The problem has to do with having Java 13 or 16 installed on your computer. The current version of Flutter does not work with Java 13 and 16. Just uninstall either of these that you may have installed and installed Java 8 or Java 11. Restart your computer to effect the update. Everything should be fine afterwards

olasammy
  • 6,676
  • 4
  • 26
  • 32
0

I got this error when using flutter. I fixed it ensuring the android-studio-dir path was set correctly. You set it up using flutter config --android-studio-dir="android studio path". Then run flutter doctor and ensure flutter can see Android Studio

Edie Kamau
  • 230
  • 1
  • 5
0

In 'adnroid/gradle/wrapper/gradle-wrapper.properties' Change distributionUrl to version 7.0.1

In 'android/build.gradle' Change 'com.android.tools.build:gradle' to version 4.2.0

0

Java 11 is the only supported version by Flutter as for now. It compiles and installs. Previously I had this error using Java 19 and Java 8.

anunezr
  • 59
  • 1
  • 7
0

You might want update your gradle version. Check the supported gradle <-> kotlin <-> java version on their page.

0

The error message you're seeing is related to the flutter build process and it occurs when a required input or output annotation is missing from the assets property of the FlutterTask.

task buildFlutter(type: FlutterTask) {
// Add the @Input annotation to the assets property
@Input List<String> assets = ["assets/images/", "assets/fonts/"]

}

0

I had the same problem. Please make sure your jdk is compatible with your android studio/adroid sdk. In my case jdk 19 was not supported with android studio electric eel so i had to install jdk 17.

DavidW
  • 29,336
  • 6
  • 55
  • 86
0

I had the same problem with React Native and I solved following the next steps:

  1. Open Android Studio

  2. File -> Open your project (select the android folder)

  3. Wait for the gradlew finish the build process

  4. Then Menu Build -> Rebuild project

  5. Now you can compile npx react-native run-android

enter image description here

Vladimir Salguero
  • 5,609
  • 3
  • 42
  • 47
0

I had a similar issue with a project. Just opening it with the Android Studio, and then running the command, seemed to resolve it for now.

Boris
  • 21
  • 7
  • As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Aug 09 '23 at 04:28
-1

I also had this problem So I just upgrade my flutter by the command flutter upgrade .

or You can Clean the Gradle cache: Similar to the previous error, you can try deleting the Gradle cache to resolve the issue. Navigate to the directory mentioned in the error message (C:\Users\loran.gradle\caches\6.8.2) and delete the scripts folder. Then, try rebuilding your project to see if the error is resolved.

  • 1
    Most or all of your eight answers from the last three days appear likely to have been entirely or partially written by AI (e.g., ChatGPT). This appears to be GPT that you've (poorly) edited. Please be aware that [posting of AI-generated content is banned here](//meta.stackoverflow.com/q/421831). If you used an AI tool to assist with any answer, I would encourage you to delete it. – NotTheDr01ds Jun 11 '23 at 12:31
  • 1
    **Readers should review this answer carefully and critically, as AI-generated information often contains fundamental errors and misinformation.** If you observe quality issues and/or have reason to believe that this answer was generated by AI, please leave feedback accordingly. The moderation team can use your help to identify quality issues. – NotTheDr01ds Jun 11 '23 at 12:31
-2

Change the JAVA_HOME to your Android Studio root such as: D:\Android\Android Studio\jbr (not jre).

I don't change the java version, just changed the JAVA_HOME, it solved this question.

RusArtM
  • 1,116
  • 3
  • 15
  • 22
  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Mar 30 '23 at 19:41
-3

Try to disable AVAST, check system vatiables path for JDK and SDK, clear cache with yarn.

Rafael
  • 107
  • 1
  • 5