I was writing my first Android Application, and suddenly when I rebuilt the application R.java file goes missing. This resulted into red underlined errors in the source code. After 2 hours of searching, I found that there could be various reasons for this, but those things could not help in my case. I continued playing around with my first application and found that I have used a string variable “title_activity_display_message” in AndroidManifest.xml file, which was not defined in res/values/strings.xml. I corrected this and I recovered R.java. Oh R.java I really missed you for around 2 hours.
Snippet from AndroidManifest.xml
<activity
android:name=".DisplayMessageActivity"
android:label="@string/title_activity_display_message">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.example.myfirstapp.MainActivity"/>
</activity>
Snippet from res/values/strings.xml
<resources>
<string name="app_name">My First App</string>
<string name="edit_message">Enter a message</string>
<string name="button_send">Send</string>
<string name="menu_settings">Settings</string>
<string name="title_activity_main">MainActivity</string>
<string name="title_activity_display_message">DisplayMessageActivity</string>
</resources>



