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.
and there is an error like:
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.