Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error in R.java

There is an error in R.java in this code on the second line

 public static final class id {
    public static final int 2ndQ=0x7f05000a;
    public static final int FirstQuestion=0x7f050000;
    public static final int MainTitle=0x7f050003;
    public static final int SecondQuestion=0x7f050008;
    public static final int btnstrt=0x7f050007;
    public static final int editText1=0x7f050001;
    public static final int imageView1=0x7f050006;
    public static final int maindescrip=0x7f050004;
    public static final int radio0=0x7f05000b;
    public static final int radio1=0x7f05000c;
    public static final int radio2=0x7f05000d;
    public static final int radioGroup1=0x7f050009;
    public static final int toq1=0x7f050005;
    public static final int toq2=0x7f050002;
    public static final int toq3=0x7f05000e;

It gives me this error

Syntax error on token "2", delete this token

I try to delete that line as it is the ID for a TextView I no longer have. Infact, I changed the ID of the TextView to "SecondQuestion" from "2ndQ".

How do I get rid of the error? It's preventing me from testing my app.

EDIT: Just to clarify this, the id is not present in my project AT ALL.

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

    <TextView
        android:id="@+id/SecondQuestion"
        android:layout_height="wrap_content"
        android:layout_width="wrap_content"
        android:layout_alignParentTop="true"
        android:layout_centerHorizontal="true"
        android:gravity="center"
        android:text="@string/secondQ"
        android:layout_marginTop="30dp"
        android:layout_marginLeft="20dp"
        android:layout_marginRight="20dp"
        android:textSize="25dp"
        android:textStyle="bold" />

    <RadioGroup
        android:id="@+id/radioGroup1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignLeft="@+id/2ndQ"
        android:layout_below="@+id/2ndQ"
        android:layout_marginTop="74dp" >

        <RadioButton
            android:id="@+id/radio0"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:checked="true"
            android:text="@string/q2Answer1" />

        <RadioButton
            android:id="@+id/radio1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/q2Answer2" />

        <RadioButton
            android:id="@+id/radio2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/q2Answer3" 
            android:gravity="center" />
    </RadioGroup>

    <Button
        android:id="@+id/toq3"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_alignParentLeft="true"
        android:text="@string/buttonForQuestion3"
        android:textSize="20dp"
        android:clickable="false" />

</RelativeLayout>
like image 989
MPKenning Avatar asked Mar 18 '26 21:03

MPKenning


2 Answers

I try to delete that line as it is the ID for a TextView I no longer have

Sounds like the R.java file has not updated, try some of these general pointers to begin with:

  • Do not manually edit any of the files in the gen folder, as these are automatically built for you.
  • If you find it is out of sync then try refreshing the project.
  • If that did not work try a clean (project -> clean)
  • If that did not work delete the gen folder, from within Eclipse, (do not panic) it will then be rebuilt by Eclipse - however if there is a coding error of some sort it may not do this straight away.
like image 125
Graham Smith Avatar answered Mar 21 '26 10:03

Graham Smith


I had a very similar error message starting off with Android development. In my case it was a simple naming error on one of the res strings - I had android:id="@+id/edit/message". The second / should have been an underscore.

The only error message was in R.java so when starting out with development was very confusing.

like image 35
dubman23 Avatar answered Mar 21 '26 10:03

dubman23



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!