Android Studio displays in all java files in red : “cannot resolve symbol R” but the project compiles and runs.
I have tried every solution here: Android Studio "cannot resolve symbol" but project compiles and works, but with no luck.
I tried to :
invalidate caches and restart android studio
delete .gradle and .idea folders
clean and rebuild the project
install a new version of android studio
mess up with gradle file then undo changes and sync project
One thing that I want to try, but I don't know how to achieve, is to reopen the project from scratch as I was opening it for the first time, but I don't know how to do this.
I also tried answers from here: Android Studio says "cannot resolve symbol" but project compiles, but again with no luck.
Android studio version = 3.2.1
dependency versions in gradle project file:
classpath 'com.android.tools.build:gradle:3.4.0-alpha01'
classpath 'com.google.gms:google-services:4.0.0'
R is a class containing the definitions for all resources of a particular application package. It is in the namespace of the application package. For example, if you say in your manifest your package name is com. foo. bar , an R class is generated with the symbols of all your resources in com.
R. java is the generated file by ADT or Android studio. It will be located under app\build\generated\source\r directory.
In JavaLanguage, if you get 'cannot resolve symbol', you have used a name that the compiler hasn't recognized. Class names -- If it is a class name, the compiler cannot find the class.
For some reason that i do not understand ,
this combination of build versions made the issue :
grade version = 4.10.1
classpath 'com.android.tools.build:gradle:3.4.0-alpha01'
when i switched to these build versions :
grade version = 4.6
classpath 'com.android.tools.build:gradle:3.2.1'
The issue was solved !
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With