R.layout.main cannot be resolved

Viewed 50683

Using Eclipse on win XP. I've previously created an app or 2, but am now working on the 'real' version and get the above error.

I was having funnies creating a 1.5 version, so have started a new project for 2.1.

package xxx.guest;

import android.R;
import android.app.Activity;
import android.content.Context;
import android.graphics.Bitmap;
import android.os.Bundle;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.TextView;

public class briefme extends Activity {

 private String strURL;
           ........
           ........ 

 @Override
 public void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.main ); 

Project as below (note I've removed some names for confidentiality reasons!)

Any ideas what's gone wrong?

Thanks,

Martin.

Project screenshot here

8 Answers

In my case this happened because their was a layout resource with upper case letters in the file name. Resources weren't compiled because of the error and because of that the R class was missing.

As suggested above, simply changing the import "import android.R;" to one relative to your app e.g. "import your.package.name.R;" should do the trick here.

Related