The R.java file should be automatically generated by Android. Try the following:
- If you are using Eclipse try “project clean” to regenerate the file.
- Try to fix all errors not related to the R file and then retry the “project clean” option. Other errors (e.g. your xml layout files) can “stall” a new build of the R file via project clean.
- Make sure your project is an Android project and you have an android.jar file on your classpath.
solved How can resolve R in Android?