R.xml.preferences cannot be found?
android, android-layout
Solution
I think you have missed an import (as said Vincent in comments). you should add:
import com.myapp.prototype.R;
The error also appears if you put in your code:
import android.R;
which is confusing because R is resolved but has no attribute that you defined in your XML file (of course, it is not the good R !).
Problem
I'm trying to set up some simple preferences for an Android app, but can't get past this error: "xml cannot be resolved or is not a field." I have cleaned, refreshed, restarted eclipse, and danced the jig - but I can't shake the error. What am I doing wrong? The preferences.xml file: ``` <?xml version="1.0" encoding="utf-8"?> <PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"> <PreferenceCategory android:title="Dev options"> <CheckBoxPreference android:key="devtools" android:title="Enable clearing user" android:summary="Enable clearing user" /> </PreferenceCategory> </PreferenceScreen> ``` The java class file: ``` package com.myapp.prototype; import android.os.Bundle; import android.preference.PreferenceFragment; public class GCPreferencesActivity extends PreferenceFragment { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Load preferences from XML resource addPreferencesFromResource(R.xml.preferences); // error on this line ?? } } ``` Thanks for any help.