However, I always tend to stop at the same point, “Trying to debug and run code”
I would like to run my first flutter project on my phone via Android Studio but there seems to be an issue with gradle that I do not understand.
I’m getting the following error message;
Launching lib\main.dart on TECNO B1p in debug mode...
Running Gradle task 'assembleDebug'...
FAILURE: Build failed with an exception.
* What went wrong:
The supplied javaHome seems to be invalid. I cannot find the java executable. Tried location: C:\Program Files\Android\Android Studio\jre\bin\java.exe
* 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
Exception: Gradle task assembleDebug failed with exit code 1
Please help me out. I don’t want to give up again on first time.
Go to the Gradle settings in Android Studio and make sure a proper JDK is selected to run Gradle.
It seems it tries to use some built-in Java that is not compatible or something like that.
Where do I locate that please? I downloaded JDK 20.0.0.2, also downloaded the Android Studio suggestion (Android API 34 Platform) but still it’s like something is missing.
Where do I locate the settings for selecting the JDK, please?
On the Gradle settings page. Just type Gradle into the search box of the settings dialog. And better use a JDK that is compatible with the Gradle version your are using: Compatibility Matrix