Android Studio “cannot resolve symbol R” but project compiles and runs
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 !
Android Studio marks R in red with error message cannot resolve symbol R, but build succeeds
Here is my temporary solution until I find a better one:
Using Everything, find where R.java is created. In my case it was
C:\Program Files (x86)\Android\android-studio\system\compiler\<project-name>.cb969c52\.generated\aapt\<module-name>.6badd9a4\production\com\<project-name>\<module-name>
In the Project view, click the module and press F4. Ignore the warning.
Click "+ Add Content Root" and select the aforementioned folder. Make sure it's marked in blue (as a source).
After I did this, suddenly all the warnings are gone. The problem is that if you collaborate with other people, the folder name is different on each machine so be careful when synchronizing.
Cannot resolve symbol R and nothing is working?
Try this:
first of all check your
XML
file where you are working now
maybe there is some problem in your XML fileafter go to in your android studio and click
file
menu in dropdown selectinvalidate cache/restart
Cannot Resolve Symbol 'R' Android Studio 3.0
Happened to me also after updating Studio and Gradle version. Even when the problem is in resource files, sometimes it might fail to indicate that. In such a scenario just close the project and import it afresh. That worked for me. The answers and comments in this question provide more details: https://stackoverflow.com/a/49537464/1877184
Error Cannot resolve symbol R only in one file
I've found out that the error with R resolving begins when the Java file is located in a subfolder of the package (for example, the ui folder).
Then Android Studio starts to import package.R
.
For example, in this case:
package com.example.test3;
there is no R error. But in this one:
package com.example.test3.ui;
R is not resolved and gets autoimported.
Maybe this is the expected behaviour.
Related Topics
How to Access My Localhost from My Android Device
How to Pass Values Between Fragments
Open Another Application from Your Own (Intent)
How to Implement Endless List With Recyclerview
Adding a Library/Jar to an Eclipse Android Project
Filter Logcat to Get Only the Messages from My Application in Android
Android Fragment No View Found For Id
Firebaseinstanceidservice Is Deprecated
How to Create an Object of an Activity in Other Class
Detect Whether There Is an Internet Connection Available on Android
How to Connect to a Specific Wi-Fi Network in Android Programmatically
What Is the Main Purpose of Settag() Gettag() Methods of View
What Permission Do I Need to Access Internet from an Android Application
Android Fragment Handle Back Button Press