Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Flutter android build.gradle unable to resolve class GradleException

In my flutter app, flutter build apk succeeds without warning but android.app.build.gradle has an error in this code:

def flutterRoot = localProperties.getProperty('flutter.sdk')
if (flutterRoot == null) {
    throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
}

The error is

unable to resolve class GradleException

whereis flutter returns "/home/mark/dev/flutter/bin/flutter".

flutter doctor -v returns Flutter version 3.3.1 on channel stable at /home/mark/dev/flutter` and has no errors.

my local.properties file contains flutter.sdk=/home/mark/dev/flutter

How can I resolve this error?

like image 595
markhorrocks Avatar asked Sep 09 '25 15:09

markhorrocks


1 Answers

Remove the new keyword before GradleException.

try this

throw GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
like image 185
ehitel rodriguez castro Avatar answered Sep 12 '25 13:09

ehitel rodriguez castro