Saturday, December 11, 2010

Android: R cannot be resolved

If you have these error this article should show you how to resolve it. But first I need to explain why you have this error. The auto generated R class is invoked in the main class. You might be tempted to resolve it by importing. Well, that won't work either. If you notice the package is the same as that of the main. Oddly enough, you just need to restart eclipse and load your project. Viola!

public class Main extends Activity {
    /** Called when the activity is first created. */
    public void onCreate(Bundle savedInstanceState) {
        TextView t = new TextView(this);
        t.setText("Hello, textview!");        

No comments:

Post a Comment