Reputation: 549
I don't know why, but ever I create new Android project this coming with error on Class R.
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
On setContentView(R.layout.activity_main)
Eclipse show me a error
R cannot be resolved to a variable
So, I try to use import android.R;
but I get other error:
activity_main cannot be resolved or is not a field
Why it happen? How I can resolve this issue? And why a New Eclipse project is already coming with error?
Thanks!
Upvotes: 0
Views: 138
Reputation: 549
Thanks guys, I deleted my Eclipse and now I using the specific Eclise for Android, downloaded on http://developer.android.com/sdk/index.html
This Eclipse is very good and my problem was solved.
Thanks everyone!
Upvotes: 1
Reputation: 26821
Don't import android.R. You need to import your own R file from the gen folder. If your R file didn't get automatically generated for you, then check for errors in your layout XML files.
Upvotes: 5