I opened my project in Android Studio yesterday and got red everywhere with 'Cannot resolve symbol' as the description. It was completely random as no changes had been made to either the project or AS since the last time I opened the project. I ended up updating Android Studio to 2.0 and trying a bunch of solutions I found online but nothing works.
Like this guy, I have already tried:
- Rebuilding the project
- Cleaning the project
- Syncing with Gradle Files
- Closing the Project, closing AS and relaunching / reopening
- File > Invalidate Caches / Restart
- Examining Lint, didn't see anything obvious
- Double checking all support libraries are up to date in the SDK manager
- Examining my Build.gradle, although no changes and it's the same as usual, the way it was working all the time.
I have also tried the following steps (from the accepted answer):
- Exiting Android Studio
- Backing up ymyour project
- Deleting all the .iml files and the .idea folder
- Relaunching Android Studio and reimporting project
I also tried:
- Removing the 'proguard' entry in build.gradle
- Changing to "Use default gradle wrapper" in preferences
Another solution is to move 'buildTypes' in build.gradle but 'buildTypes' is already at the bottom of the Android section
Don't mark this as a duplicate if the "duplicate" is someone who fixed the same problem by doing something that didn't fix my problem.
Here are some screenshots:
As you can see, the color 'white' does exist:
R errors everywhere as well:
These errors are everywhere too:
Why are there two res
directories and why is the one with the necessary resources a sub-directory of the java
directory? Could this be related? Screenshot here:
EDIT: I created a drawable
directory in the main res
directory and added one of the drawables that won't get picked up by build variants. It removed the relevant 'Cannot resolve symbol' error. But when I deleted the main res
and tried try to move the whole res directory in the java
subdirectory to the main
directory I got the following error:
EDIT: I managed to build without errors by deleting the outer res
directory, copying the one inside the java
one, pasting that into the main
directory then deleting the one inside the java
directory. How these got moved around like that I do not know. Probably caused by following the 'solution' of deleting and importing the project again. Whether it actually runs properly on a device I do not know as Android Studio is hanging for the last 20-30 minutes (as it does sometimes). If it does I may answer my own question with what I did to finally fix the problem.