Roy Hinkley
Roy Hinkley

Reputation: 10641

android studio cannot resolve symbol 'GradleException'

Creating new Android Studio project get the following exception in Gradle build file:

Cannot resolve symbol 'GradleException'

enter image description here

Gradle still builds successfully, but still shows this error in editor.

What's missing from my project?

Android Studio 3.3.2

Gradle 4.10.1

compileSdkVersion 27

Upvotes: 72

Views: 93546

Answers (4)

Trinh Hieu
Trinh Hieu

Reputation: 803

The error is misunderstood by Android Studio, you should not remove new section from it because you will build release an error:

def localPropertiesFile = new File(rootProject.projectDir, "local.properties")
def attribute = new Attribute()

No delete new

Upvotes: 1

Pranav Dave
Pranav Dave

Reputation: 804

For flutter specific, It won't throw an error. But if you don't want those Red letters then you can replace

GradleException

with

RuntimeException

Upvotes: 11

amm98d
amm98d

Reputation: 2145

The latest Android SDK does not support GradleException(), instead use FileNotFoundException().

Or for future readers, maybe use RuntimeException (if the issue is not file related).

I found the issue and the solution on this GitHub thread:
https://github.com/flutter/flutter/issues/29608

Upvotes: 192

Zoe - Save the data dump
Zoe - Save the data dump

Reputation: 28258

Note: this answer is no longer up-to-date for newer versions of Android Studio and Gradle. See this answer instead.

Android Studio seems to have various problems that I cannot understand why exist, but they're fixed by invalidating the caches and restarting (from the file menu item). Because the code compiles fine, it seems that this is one of those cases, in which a cache entry somehow ends up, I'm not really sure what specifically happens, but essentially something that prevents it from working properly.

So invalidating the caches and restarting may issues like this, whether it's with Gradle or with Java/Kotlin/Scala/<insert language here>.

Upvotes: 21

Related Questions