Android Studio 2.1, Java V8 Update 91, Gradle 2.1.0 .
I know that this questions has been asked many times here, but none of the recommendation solutions works out.
Sometimes the R.java class is not created when there is some error into an xml file (like activity_main.xml). For example, if you change some attribute name that has a reserved word that cannot be changed.
Like this: if you changed the attribute called: id to another name like
id_A_Word_With_Error_Here in this code that can be part of the activity_main.xml, your error (R class not created) can occur.
<android.support.v7.widget.RecyclerView
android:id="@+id/messageRecyclerView"
and there is an error like:
<android.support.v7.widget.RecyclerView
android:id_A_Word_With_Error_Here="@+id/messageRecyclerView"
If clean, rebuild did not work and there is no error with import like import com.something...
, my suggestion is to search an error into xml files.
Try syncing the project, go to Tools > Android > Sync Project with Gradle Files
UPDATE
If you're using Android Studio 3.3, use the Sync Project with Gradle Files
icon
Have you tried Rebuild Project go to Build> Rebuild Project and perform it without doing the Clean project I had the same problem & it worked for me