Question

I am getting a 'ID cannot be resolved or is not a field' error. I reckon it is because the R file is not being generated due to some error int he XML file. There are no yellow or red markers in the XML file on Eclipse ADT though. I can't spot the error in my XML posted below.

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

<com.androidplot.xy.XYPlot
    android:id="@+id/plot"
    android:layout_width="fill_parent"
    android:layout_height="145sp"
    android:layout_alignParentBottom="true"
    android:layout_alignParentLeft="true"
     />

<ImageView
    android:id="@+id/imageView1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentLeft="true"
    android:layout_alignParentTop="true"
    android:layout_marginTop="14dp"
    android:src="@drawable/battery4" />

<TextView
    android:id="@+id/batterylevel"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentLeft="true"
    android:layout_alignRight="@+id/imageView1"
    android:layout_below="@+id/imageView1"
    android:gravity="center"
    android:text="50%" />

<TextView
    android:id="@+id/duration"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_below="@+id/imageView2"
    android:layout_centerHorizontal="true"
    android:gravity="center"
    android:text="2h 30m" />

<TextView
    android:id="@+id/TempDisp"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignBaseline="@+id/duration"
    android:layout_alignBottom="@+id/duration"
    android:layout_alignLeft="@+id/imageView3"
    android:layout_alignParentRight="true"
    android:gravity="center"
    android:text="20C" />

<ImageView
    android:id="@+id/imageView4"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentLeft="true"
    android:layout_below="@+id/batterylevel"
    android:layout_marginTop="15dp"
    android:src="@drawable/phpKSlCAiPM" />

<TextView
    android:id="@+id/VoltDisp"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignBaseline="@+id/availMem"
    android:layout_alignBottom="@+id/availMem"
    android:layout_alignLeft="@+id/imageView5"
    android:layout_alignRight="@+id/imageView5"
    android:gravity="center"
    android:text="3856 mV" />

<TextView
    android:id="@+id/availMem"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentLeft="true"
    android:layout_alignRight="@+id/imageView4"
    android:layout_below="@+id/imageView4"
    android:gravity="center"
    android:text="300 MB" />

<ImageView
    android:id="@+id/imageView2"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_above="@+id/batterylevel"
    android:layout_centerHorizontal="true"
    android:src="@drawable/phpcBJhcgPM" />

<ImageView
    android:id="@+id/imageView8"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_above="@+id/VoltDisp"
    android:layout_alignParentRight="true"
    android:src="@drawable/phpzExQOSPM" />

<ImageView
    android:id="@+id/imageView5"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_above="@+id/VoltDisp"
    android:layout_alignLeft="@+id/imageView2"
    android:src="@drawable/phpeVVENPPM" />

<ImageView
    android:id="@+id/imageView3"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignLeft="@+id/imageView8"
    android:layout_alignTop="@+id/imageView2"
    android:src="@drawable/phpKdWu9vPM" />

<TextView
    android:id="@+id/cores"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignBaseline="@+id/VoltDisp"
    android:layout_alignBottom="@+id/VoltDisp"
    android:layout_alignLeft="@+id/imageView8"
    android:layout_alignRight="@+id/imageView3"
    android:gravity="center"
    android:text="4 cores" />

<ImageView
    android:id="@+id/imageView7"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignLeft="@+id/VoltDisp"
    android:layout_alignTop="@+id/imageView6"
    android:src="@drawable/phppcdZ0aPM" />

<TextView
    android:id="@+id/bluetoothstatus"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignBottom="@+id/wifistatus"
    android:layout_alignLeft="@+id/imageView7"
    android:layout_alignRight="@+id/imageView7"
    android:gravity="center"
    android:text="OFF"
    android:textSize="12sp" />

<ImageView
    android:id="@+id/imageView9"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignLeft="@+id/cores"
    android:layout_alignTop="@+id/imageView7"
    android:src="@drawable/phpnGkpNbPM" />

<TextView
    android:id="@+id/timestamp"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignBottom="@+id/bluetoothstatus"
    android:layout_alignLeft="@+id/imageView9"
    android:layout_alignParentRight="true"
    android:gravity="center"
    android:text="12:23:04" />

<TextView
    android:id="@+id/wTimer"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_above="@+id/plot"
    android:layout_alignParentLeft="true"
    android:layout_alignRight="@+id/cores"
    android:gravity="center"
    android:text="X" />

<TextView
    android:id="@+id/wifistatus"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_above="@+id/wTimer"
    android:layout_alignParentLeft="true"
    android:gravity="center"
    android:text="CONNECTED"
    android:textSize="12sp" />

<ImageView
    android:id="@+id/imageView6"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_above="@+id/timestamp"
    android:layout_alignParentLeft="true"
    android:src="@drawable/phpOIVnXLPM" />

 </RelativeLayout>
Was it helpful?

Solution

Drawable Resources have incorrect names, that's why R file isn't generated.

Incorrect names are : phpOIVnXLPM, phpKSlCAiPM etc.

If you use an IDE, you will see the following restriction is displayed:

File-based resource names must contain only lowercase a-z, 0-9, or _.

OTHER TIPS

Is it possible that this error occurs because you have named string and id the same?

and even

It seems project is not compiled yet. Clean your project by right click on project. If no compilation errors(red marks) in xml, clean should resolve the issue.

Your all Drawable Resources should have lowercase letter but by having a look at your XML it looks like you have some drawable resource ,those who named in Capital letter , here it is

android:src="@drawable/phpKSlCAiPM"

Clean your project and Re-build.If still error comes then restart your eclipse IDE and import your project.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top