김동구
김동구

Reputation: 51

Cannot Resolve Symbol 'Properties' on Android Studio

There are two errors in my Android Studio right now. In the app level build.gradle folder, the line

def localProperties = new Properties()

shows error Cannot Resolve Symbol 'Properties' and on

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.")
}

it says Cannot Resolve Symbol GradleException, What should I do to solve these two errors?

Upvotes: 5

Views: 6733

Answers (5)

Srikanth
Srikanth

Reputation: 1

Symbol Properties solution worked fine.

For GradleException you need to set the path for Gradle in Settings. You need to go to Settings From File Click Settings. After Clicking Settings Click Path Variable Add path to Gradle as follows:

\AndroidStudioProjects\Project_directory\wrapper\dists\gradle-7.3.3-all\4295vidhdd9hd3gbjyw1xqxpo\gradle-7.3.3\bin

GradleException error got solved for me. If you are using Windows set the path similar under Environment Variable

Upvotes: 0

IdemudiaMonday O.
IdemudiaMonday O.

Reputation: 31

I had the same problem lately, but I resolved it with the following steps;

  1. To resolve Symbol 'Properties' issue;

def localProperties = new Properties()

Remove/delete the keyword >> new << from the above instance, the syntax is not needed/depercated.

def localProperties = Properties() #"use it like this"

  1. To resolve Symbol GradleException issue;

    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 solution I used was to import the class;

`import com.GradleException`    

Copy and paste it to the first line of the file; ...app/build.gradle

Hope this would help.

Upvotes: 3

Abdul Agfar
Abdul Agfar

Reputation: 69

Set Project SDK to Android API Platform version 29 (or the latest version, 30), like so:

Step 1:

defaultConfig {
    ...
    minSdkVersion 16
    targetSdkVersion 30
}

Step 2:

update GradleException() to FileNotFoundException()

Step 3:

Please follow this: https://github.com/flutter/flutter/issues/29608#issuecomment-548649907

Upvotes: 3

Eslam Sameh Ahmed
Eslam Sameh Ahmed

Reputation: 4012

Remove new

def localProperties = Properties()

Upvotes: 4

Orange
Orange

Reputation: 389

In my case, it's nothing about the Properties, nor the SDK/Gradle versions... etc. It's simply because something is missing in the build.gradle. The error message is just the result but not the cause. Carefully examine every line in build.gradle.

In my case, it took about one day to find out that something should be defined in local.properties but wasn't there. So the sync for build.gradle failed. And then, the only one line in red is the Properties....

Upvotes: 1

Related Questions