Nicky Mirfallah
Nicky Mirfallah

Reputation: 1054

Android Studio cannot resolve symbol 'android'

I am doing a project in Android Studio and today I saw that suddenly all my code has errors and even the line:

import com.google.android.gms.appindexing.Action;

has error: cannot resolve symbol android

any suggestions why this might have happened?

Upvotes: 1

Views: 7705

Answers (5)

Steve White
Steve White

Reputation: 450

What I did: in Android Studio Settings --> Build, Execution, Deployment Build Tools --> Gradle I had set the value of the field Gradle User Home.

I did that, because it was displaying a wrong path (perhaps from an earlier installation?) But what I put in was really a guess.

But it caused several problems, including a thousand warnings "cannot resolve symbol 'android'"

I fixed it by emptying the field (then Clean Project, then in Terminal ./gradlew clean, then File --> Invalidate Caches... because ... who knows? does anybody really know?)

Upvotes: 0

Lindo Alex
Lindo Alex

Reputation: 1

solved this issue by -> clean project - > save all - > close all tabs -> Close entire project -> Reopen it again.

The issue solved

Upvotes: 0

Farid Haq
Farid Haq

Reputation: 4191

Please try as follows

  1. Exit Android Studio
  2. Back up your project
  3. Delete all the .iml files and the .idea folder
  4. Relaunch Android Studio and reimport your project

or

  1. Exit Android Studio
  2. Back up your project or rename your project
  3. Clone new project

Upvotes: 0

X-Black...
X-Black...

Reputation: 1596

1st update your SDKs ( Android tools SDK & Google play service)

in your build.gradle "modules" include this code in your dependencies

compile 'com.google.android.gms:play-services-places:<version>

where is the latest version available...my version at the time of this answer is 11.0.4

Upvotes: 0

Pragati Singh
Pragati Singh

Reputation: 2523

Please ensure you have mention in your project grades it has been tested and working fine

dependencies {
  ...
  compile 'com.google.android.gms:play-services-appindexing:8.4.0'
  ...
}

clean your project and rebuild again and wait till android studio make indexing and loaded all resource some time due to system it will slow. please comment if you found something else. happy coding :)

Upvotes: 2

Related Questions