Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Could not find method File() for arguments

I'm having this error while running my flutter app, there is something wrong with my settings.gradle file.

My android sdk location:"F:\AndroidSdk" My flutter sdk location:"F:\FlutterSdk"

...................ERROR.......................
FAILURE: Build failed with an exception.

* Where:
Settings file 'E:\rider_app-master\android\settings.gradle' line: 3

* What went wrong:
A problem occurred evaluating settings 'android'.
> Could not find method File() for arguments [E:\rider_app-master\android, local.properties] on settings 'android' of type org.gradle.initialization.DefaultSettings.

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

My setting.gradle file (there is no error but still can't run my app)

include ':app'

def localPropertiesFile =  File(rootProject.projectDir, "local.properties")
def properties =  Properties()

assert localPropertiesFile.exists()
localPropertiesFile.withReader("UTF-8") { reader -> properties.load(reader) }

def flutterSdkPath = properties.getProperty("flutter.sdk")
assert flutterSdkPath != null, "flutter.sdk not set in local.properties"
apply from: "$flutterSdkPath/packages/flutter_tools/gradle/app_plugin_loader.gradle"
like image 248
Sahil Rana Avatar asked Dec 05 '25 18:12

Sahil Rana


1 Answers

I had the same issue and (for some reason) the .gradle files in the project didn't have the "new" keyword when creating objects.

Open your build.gradle (in android/app) and settings.gradle, look for Properties(), GradleException(), File() etc and add "new" before. That solved it for me.

like image 57
Mateus Avatar answered Dec 08 '25 09:12

Mateus



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!