63

I'v just installed Android Studio 0.8.2 for my first time and I have a lot of "Cannot resolve symbol" errors. The errors occur on both new projects and projects which were exported from eclipse.

JDK version: jdk1.8.0_11

Android studio errors: Android studio errors

Project's grade file enter image description here

Community
  • 1
  • 1
Idob
  • 1,620
  • 4
  • 16
  • 27
  • If your library is an `androidx` one and never worked before, the problem is likely the one described in [this other question](https://stackoverflow.com/questions/60722739/) instead. – Davide Mar 17 '20 at 14:08

8 Answers8

153

You can do "File" -> "Invalidate Caches...", and select "Invalidate and Restart" option to fix this.

Priyanthi
  • 1,715
  • 2
  • 10
  • 7
27

Android Studio suddenly cannot resolve symbols helped:

  • Exit Android Studio
  • Back up your project
  • Delete all the .iml files and the .idea folder
  • Relaunch Android Studio and reimport your project
serv-inc
  • 35,772
  • 9
  • 166
  • 188
19

In the menu bar

Select tools>-android>-SDK manager

and download the SDK build tools, SDK platform and Google API's( the Google API stores packages such as "import android.view.Menu" etc.) for the target SDK version of your project(20 as shown in your screenshot). if you are not sure which items you have to download , you can select all of them.(will take more time to download of course).

Restart the IDE

Akshit Rewari
  • 941
  • 2
  • 13
  • 26
  • 1
    SDK build tools and SDK platform already installed for API 20. But I don't see Google API's for API 20 (I have only for API 19), what should I do? – Idob Jul 26 '14 at 16:17
  • ok, I just checked the versions of SDK and api level 20 is for android wear, api level 19 is for android kitkat. Now unless you are designing for android smartwatches , I'd suggest changing targetsdk to '19' and check if all the build tools for api 19 are installed. If it still doesn't work ,install all of them(no harm in trying) . Restart IDE and check. – Akshit Rewari Jul 26 '14 at 17:04
  • In my case the problem occured due to a broken SDK Platform installation. I uninstalled the Android version corresponding to the 'compileSdkVersion' (removed the checkmark in the SDK Manager). Then I checked the same platform version again in the SDK Manager and downloaded it again. This worked out for me. – Jeff S. Feb 21 '20 at 09:22
  • 1
    I found the solution to my problem under File -> Settings -> Appearance and Behavior -> Android SDK. Make sure the Android version with the API-level specified in your Gradle file is installed. – kling May 26 '21 at 12:25
  • Worked for me. Lesson learned: have both target and compile SDK tools installed, IDE won't do it for you – amartin1911 Jun 21 '22 at 18:39
1

Delete folder: C:\Users\{your-user}\.AndroidStudio{your-version}\system\caches

It helped me

Albert
  • 163
  • 2
  • 7
1

I cannot explain logic behind this one but it absolutely worked for me. For the symbol that is being shown in red or gives error of 'Cannot resolve', press backspace and type that particular symbol again.

Again, it's crazy but worked for me

1

Apparently the xml must be in the "drawable" folder. That fixed it for me.

pedagogyfirst
  • 43
  • 1
  • 8
  • You answer is not clear. – MAC Dec 26 '21 at 07:35
  • 1
    @MAC Sry, I misunderstood the OP's code. In that case I agree with the top answer of restarting Android Studio and invalidate caches. I basically was doing a custom look for buttons and switches, and to do that I was writing a xml file using ` – pedagogyfirst Dec 29 '21 at 00:12
0

I run into the same problem, i solved it by performing a clean project. To do this go to;

Select build>-clean project>

0

Did you install any plugins before this issue started occurring? I installed the CSVreader plug in and it took me forever to find out what the problem was. Look at the bottom right of the screen and see if there is a red dot. If it is there, click on it, it should list out lots of errors and above that it will say "uninstall plug in" next to the plug in that has the issue with it. click that, restart Android studio and your problem will be fixed (if a Plugin is the issue).