Search code examples
androidr.java-file

Android R not generating, even after following every single step on the internet


The android R has been troubling me for quite some time now. I have seen it in a lot of projects of mine, sometimes they just disappear, sometimes I have had to recreate a project, etc. Still this does not solve anything for my current project.

Logically I suspect the XML files to contain an error but I am unable to find it.

I am using Eclipse as my development environment and this is my main.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >

    <ImageView
        android:id="@+id/imgLogo"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:contentDescription="@string/title"
        android:src="@drawable/ic_launcher" />

    <TextView
        android:id="@+id/textView1"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:gravity="center"
        android:text="@string/title"
        android:textAppearance="?android:attr/textAppearanceLarge" />

    <Button
        android:id="@+id/btnNewTime"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:text="@string/overview" />

    <Button
        android:id="@+id/btnOverview"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:text="@string/overview" />

    <Button
        android:id="@+id/btnValues"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:text="@string/values" />

    <Button
        android:id="@+id/btnExit"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:text="@string/exit" />

</LinearLayout>

This is my strings.xml

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <string name="app_name">Werkregistratie</string>
    <string name="title">Werkregistratie</string>
    <string name="overview">Overzicht</string>
    <string name="values">Salaris/reiskosten aanpassen</string>
    <string name="exit">Afsluiten</string>
</resources>

I am unable to find the problem so I really hope you can help me out.


Solution

  • Ok this seems to be just a bug in eclipse, quite some answers are partially correct. Make sure the names validate(you can use Lint in some cases). Make sure the xmls validate. Then check your buildpath for errors. After that do a project clean and all should be fine.

    Also, this problem doesn't appear as much in the new android sdk's so they fixed something it seems.