问题
I cleaned my project and now I get a "R cannot be resolved to a variable." It was fine before I cleaned it.
I have tried cleaning it again, building the project again, creating a new project and copying all my files over, and I've gone to the Android SDK Manager and installed all the "Android SDK Build-tools" to Install all the options like the other stackoverflow posts have mentioned:

Can anyone suggest anything?

The above picture shows my generated files and lack of an R.java file.

The above picture shows my problems log.
回答1:
Make sure R is in the same package as the file where you want to call it from. (or import the package in the source file)
To change the package of the R file open your App Manifest file and change packge="" to the same package as where your source files are in.

回答2:
maybe you import take other thing
See package main import in your code should be like this example:
import com.mypackageprincipal.R;
other import of R delete only should exist it
and after clean and build your project
来源:https://stackoverflow.com/questions/21768370/r-cannot-be-resolved-to-a-variable