I am facing the typical cannot resolve symbol R
problem in Android Studio after moving some Class and XML files to a new com.android.library
module from my main com.android.application
module.
I tried already to Invalidate Caches/Restart
and Cleaning/Rebuilding
my project several times. I also deleted the .iml files of my project and restarted Android Studio.
Nothing has worked so far and I can't seem to find any specific pointer to the actual error. I think it should be an XML problem as it is often the case.
Is there a way to check the XMLs for errors in a more systematic way than opeing all the files and copy editing them line by line? The Messages Gradle Build
window is not showing any XML conflict.
As an extra, one interesting thing is that Android Studio recognizes some of the references to XML resources, even in this broken state.
In this case it is recognizing a resource linked from a different module referenced in Java even if the R class is not recognized nor imported:
In this case, it is recognizing a string resource on the same module in XML:
Could it be an issue with Android Studio itself?
Is there a way to check the XMLs for errors in a more systematic way than opeing all the files and copy editing them line by line?
You could try analysing the code with Lint. Maybe analyse the whole project in case it's not actually an xml problem, although it often is with R errors. Right click project -> Analyse -> Inspect Code
https://developer.android.com/studio/write/lint.html
In Android Studio 3.3.2 Go To Tools> XML ACTIONS > VALIDATE Its redirects to the xml in which you making mistake.
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