0

I did clean project and now i cannot run any of my code. Any files that has to do with R, just says cannot be resolved as a field. I've looked at so many other stackoverflow posts with similar problems but none seems to actually help. Help please!!

I have about 15 classes but here is an example

package com.Class;


import android.content.SharedPreferences;
import android.os.Bundle;
import android.preference.PreferenceActivity;
import android.preference.PreferenceManager;

public class NewAccount extends PreferenceActivity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        addPreferencesFromResource(R.xml.preferences);

        SharedPreferences sp = PreferenceManager
                .getDefaultSharedPreferences(this);

    }
}
Andrie
  • 176,377
  • 47
  • 447
  • 496
The Tokenizer
  • 1,564
  • 3
  • 29
  • 46

2 Answers2

3

If R.java is not being generated, chances are there are some other errors in your code than the ones referring to the R file. Find these errors, solve them, and then R will be regenerated.

nhaarman
  • 98,571
  • 55
  • 246
  • 278
  • 2
    Make sure the Problems view is open; it will report other problems in the project, such as invalid XML, buil path problems, Java compilation errors, etc. – E-Riz Feb 28 '12 at 21:15
0

Did you import the R file?

import com.example.myapp.R;

This may be useful too: R cannot be resolved - Android error

Community
  • 1
  • 1
Sid
  • 7,511
  • 2
  • 28
  • 41
  • Try adding a new Android layout XML file from Eclipse? Specifically pick "Android XML file" from the eclipse menu. – Sid Feb 29 '12 at 00:26