Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Studio "cannot resolve symbol" but project compiles and works

The project compiles fine. However, Android studio 3.0.1 shows reference to one particular library in red and displays "cannot resolve symbol". Even single stepping into that library module doesn't work.

I already tried various options like 1) Invalidate cache/restart 2) deleted build directory 3) clean and rebuild but nothing seems to be working.

Interestingly, when Android Studio is rebuilding indexes after invalidate/restart, it momentarily shows that library references in while but then again in red.

like image 635
mesibo Avatar asked Dec 20 '17 16:12

mesibo


People also ask

What is Cannot resolve symbol in Android Studio?

Most often “R cannot be resolved” error appears if there is an issue with some of your resource files. Due to this error, you are unable to build your application. That's why we need to solve this error as it not getting away by just doing a simple restart or hitting Alt+Enter.

What does Cannot resolve symbol mean?

“cannot resolve symbol” means that the Java compiler cannot locate a symbol referenced in your Java source code. The causes for this common error include: A missing class file. A faulty CLASSPATH.


1 Answers

I tried Invalidate cache/restart or clean Project -> rebuild project. These didn't work for me.

The final solution was open Project window on the left side of IDE, under Project mode, delete .gradle and .idea folder, then sync, it works.

like image 197
TaoBit Avatar answered Sep 20 '22 08:09

TaoBit