Cannot Resolve Symbol 'Properties' on Android Studio

Viewed 3701

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?

5 Answers

Remove new

def localProperties = Properties()

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....

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.

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

Related