There is a error in android studio but same code working on flutlab.io - flutter

i tried to run a basic code in android studio. but it showing error. but the same code successfully compiled on flutlab.io
here is the error message.
Running Gradle task 'assembleDebug'...
FAILURE: Build failed with an exception.
* What went wrong:
Could not open settings generic class cache for settings file 'C:\Users\HP\AndroidStudioProjects\helloapp\android\settings.gradle' (C:\Users\HP\.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'm new to android studio. so please tell what's the wrong here.

Try to use JAVA SDK 15.
First remove your old JDK, and download & install Java JDK 15 from here.
Then, in Android Studio, change the path to the Java JDK so that it matches the latest install. Finally, restart Android Studio to apply the changes.

Related

Gradle failed to build on a new hardware using the same installation method

After I copy my project to a new laptop, I tried to run a flutter project in vscode. however during debugging gradle failed to build and gave me this in the debug console
Launching lib\main.dart on sdk gphone64 x86 64 in debug mode...
lib\main.dart:1
FAILURE: Build failed with an exception.
What went wrong:
Could not open settings generic class cache for settings file 'D:\PROJECT_NAME\android\settings.gradle' (C:\Users\Folder.gradle\caches\7.4\scripts\ea4ydi90mwjg9g63m7r6nimmx).
BUG! exception in phase 'semantic analysis' in source unit 'BuildScript' Unsupported class file major version 63
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 1s
Exception: Gradle task assembleDebug failed with exit code 1
Exited (sigterm)
I have no idea what went wrong since the JDK is the same version (19) as my old laptop
edit: I tried to download a new gradle, and create a new empty project, and I still get the same error
Running a flutter project on the new laptop

I've been taking an error in flutter and couldn't fix it

Even I remove and setup again nothing changed.
error
FAILURE: Build failed with an exception.
* What went wrong:
Could not open settings generic class cache for settings file 'C:\Users\Ozgur\Documents\flutterprojects\android\settings.gradle' (C:\Users\Ozgur\.gradle\caches\7.4\scripts\ea4ydi90mwjg9g63m7r6nimmx).
> BUG! exception in phase 'semantic analysis' in source unit '_BuildScript_' Unsupported class file major version 63
* 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 1s
Exception: Gradle task assembleDebug failed with exit code 1
I remove program and setup again added JAVA_HOME path and reinstall Java JDK-19 and didn't fix
it looks like gradle cache issues, remove the cache and re-install it via android studio, i will auto-install it based on the version you specified.
I recently fixed error it's happening due to gradle version and JDK version aren't capatible. There are 2 solution one of them is remove JDK 19 completelty and install JDK 17 instead of it. Or edit link in gradle-wrapper.properties like this gradle-7.4-all.zip

NDK not configured. Download it with SDK manager when compile flutter app

Today when I compile the flutter(2.5.1) app, show error like this:
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring project ':system_clock'.
> NDK not configured. Download it with SDK manager. Preferred NDK version is '21.1.6352462'.
* 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 1s
Exception: Gradle task assembleDebug failed with exit code 1
I have already checked the NDK configuration and make sure the version is installed:
why the project prefer another version of NDK version? what should I do to configure the right version of NDK?
Just check '21.1.6352462' in NDK and press ok.
It'll do the rest.
Or check this issue
https://github.com/flutter/flutter/issues/53657

Execution failed for task ':app:compileDebugKotlin'. Make sure Gradle is running on a JDK, not JRE

Installed Android Studio and flutter sdk (downloaded zip and unzip) on my mac. I created new flutter simple project on android studio app and ran it. Then, I got following error message.
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:compileDebugKotlin'.
> Kotlin could not find the required JDK tools in the Java installation '/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home' used by Gradle. Make sure Gradle is running on a JDK, not JRE.
* 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 5s
Exception: Gradle task assembleDebug failed with exit code 1
Error message
cd /Applications/Android\ Studio.app/Contents/jre
ln -s ../jre jdk
ln -s "/Library/Internet Plug-Ins/JavaAppletPlugin.plugin" jdk
flutter doctor -v
I ran above commands in terminal and it is solved.

Exception: Gradle task assembleDebug failed with exit code 1 (runs at web but doesn't at emulator)

I'm having this issue when I try to run the standard flutter new project app:
Launching lib\main.dart on sdk gphone x86 in debug mode...
Running Gradle task 'assembleDebug'...
FAILURE: Build failed with an exception.
* Where:
Build file 'E:\AndroidStudioProjects\good_heart\android\app\build.gradle' line: 24
* What went wrong:
A problem occurred evaluating project ':app'.
> Failed to apply plugin [id 'com.android.internal.version-check']
> Minimum supported Gradle version is 6.5. Current version is 4.10.2. If using the gradle wrapper, try editing the distributionUrl in E:\AndroidStudioProjects\good_heart\android\gradle\wrapper\gradle-wrapper.properties to gradle-6.5-all.zip
* 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 16s
Exception: Gradle task assembleDebug failed with exit code 1
This happens when I try to run it in a android emulator (one provided by android studio), doesn't happen when I run it in Edge(web) though, it runs smoothly.
Any thoughts? Already tried installing older versions of JDK (such as 11 and 8). Reinstalling Android Studio and flutter... Running it from VScode outputs the same error.
If you Use Android Studio Emulator
Open AVD Manager then select your Emulator right click it and select or click on Wipe data or Cold Boot Now and then run or launch your app your project
hope its help to you
you need to update your Gradle wrapper
go to android/gradle/wrapper/gradle-wrapper.properties and change the last line to: distributionUrl=https://services.gradle.org/distributions/gradle-6.7-all.zip Android Studio will download the necessary library.