Search code examples
javaandroidxmleclipser.java-file

Error When Adding XML Files to Android Project in Eclipse


Okay, sorry for asking this question. I have no idea how to solve this problem. I am creating a new project in eclipse, put some XML files in res/layout folder, and then drag an drop existing java files to src folder. I tried to generate R.java by cleaning the project and then these error messages appear:

[2014-02-10 18:28:01 - EventPlanner] W/ResourceType( 7228): ResXMLTree_node size 0xffffffff or headerSize 0xffff is not on an integer boundary.
[2014-02-10 18:28:01 - EventPlanner] E:\Andika\workspaces\EventPlanner\res\layout\activities_list.xml:6: error: Error: No resource found that matches the given name (at 'id' with value '@id/activity_id').
[2014-02-10 18:28:01 - EventPlanner] E:\Andika\workspaces\EventPlanner\res\layout\activities_list.xml:7: error: Error: No resource found that matches the given name (at 'id' with value '@id/chk_box').
[2014-02-10 18:28:01 - EventPlanner] E:\Andika\workspaces\EventPlanner\res\layout\activities_list.xml:10: error: Error: No resource found that matches the given name (at 'id' with value '@id/res_text').
.....

And R.java file wasn't generated. I have tried to close the eclipse and then re open again but it doesn't solve my problem. Did I miss something? Thank you

Edit: this is one of my XML layout

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout android:orientation="vertical" android:background="@color/black" android:layout_width="fill_parent" android:layout_height="fill_parent"
  xmlns:android="http://schemas.android.com/apk/res/android">
    <LinearLayout android:orientation="vertical" android:paddingLeft="10.0dip" android:paddingTop="10.0dip" android:paddingRight="10.0dip" android:paddingBottom="5.0dip" android:layout_width="fill_parent" android:layout_height="wrap_content">
        <LinearLayout android:background="@drawable/cell_shape_login_form" android:layout_width="fill_parent" android:layout_height="wrap_content">
            <ImageView android:layout_gravity="center" android:id="@id/imageView1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/ic_action_person" />
            <EditText android:textColor="@color/black" android:id="@id/username" android:layout_width="fill_parent" android:layout_height="wrap_content" android:hint="Username" android:ems="20" android:layout_weight="1.0" android:inputType="textPersonName" />
        </LinearLayout>
    </LinearLayout>
    <LinearLayout android:orientation="vertical" android:paddingLeft="10.0dip" android:paddingTop="5.0dip" android:paddingRight="10.0dip" android:paddingBottom="5.0dip" android:layout_width="fill_parent" android:layout_height="wrap_content">
        <LinearLayout android:orientation="horizontal" android:background="@drawable/cell_shape_login_form" android:layout_width="fill_parent" android:layout_height="wrap_content">
            <ImageView android:layout_gravity="center" android:id="@id/imageView2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/ic_action_secure" />
            <EditText android:textColor="@color/black" android:id="@id/password" android:layout_width="fill_parent" android:layout_height="wrap_content" android:hint="Password" android:ems="20" android:layout_weight="1.0" android:inputType="textPassword">
                <requestFocus />
            </EditText>
        </LinearLayout>
    </LinearLayout>
    <TextView android:textColor="@color/BlueDefault" android:id="@id/TextView01" android:paddingLeft="10.0dip" android:paddingRight="10.0dip" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Login as" />
    <LinearLayout android:orientation="vertical" android:paddingLeft="10.0dip" android:paddingTop="5.0dip" android:paddingRight="10.0dip" android:paddingBottom="5.0dip" android:layout_width="fill_parent" android:layout_height="wrap_content">
        <Spinner android:entries="@array/account_type" android:id="@id/spinner1" android:background="@drawable/cell_shape_login_form" android:paddingLeft="10.0dip" android:paddingTop="5.0dip" android:paddingRight="10.0dip" android:paddingBottom="5.0dip" android:layout_width="fill_parent" android:layout_height="wrap_content" android:prompt="@string/manager" />
    </LinearLayout>
    <LinearLayout android:orientation="horizontal" android:paddingLeft="5.0dip" android:paddingRight="5.0dip" android:layout_width="fill_parent" android:layout_height="wrap_content" style="?android:attr/buttonBarStyle">
        <Button android:id="@id/cancel" android:background="@drawable/button_clicked" android:layout_width="0.0dip" android:layout_height="wrap_content" android:text="Cancel" android:layout_weight="0.5" style="?android:attr/buttonBarButtonStyle" />
        <Button android:id="@id/signin" android:background="@drawable/button_clicked" android:layout_width="0.0dip" android:layout_height="wrap_content" android:text="Sign in" android:layout_weight="0.5" style="?android:attr/buttonBarButtonStyle" />
    </LinearLayout>
    <TextView android:textColor="@color/BlueDefault" android:id="@id/signup" android:paddingLeft="10.0dip" android:paddingRight="10.0dip" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Don't have any account? click here to sign up" />
</LinearLayout>

Solution

  • Where ever you getting the error in xml file.

    1) Just delete that whole id and rename it again with new id name.

    2) I can see you are also getting errors while setting styles and background resources. just delete and define it again in your xml file and clean your project.

    I hope this resolves your problem.....