0

Hey everybody i know this question has been asked many times before. i have tried all the possible solutions given but i still havent been able to get the solution.

Here is my code:

package com.example.newp;
import com.example.newp.R;
import android.app.Activity;
import android.os.Bundle;
public class MainActivity extends Activity {

 @Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
 }

}

PS: Ive tried cleaning my project. I removed import android.R; Its still not working. Please help out. Im unable to progress forward because of this bug.

  • Check again. Make sure no errors in xml etc. This error, while annoying, is caused by few possibilities. – Phix Aug 30 '13 at 16:50
  • make sure you don't have errors on your xml.. example using uppercase letters for you layout names – Tobiel Aug 30 '13 at 16:52
  • Possible dup: http://stackoverflow.com/questions/18279379/why-doesnt-r-java-find-my-layout – An SO User Aug 30 '13 at 16:59
  • Check your string resource values. Sometimes there is an error that doesn't show in eclipse. As always, clean project before running it. – MattMatt Aug 30 '13 at 17:14

3 Answers3

0

This should work. Make sure that your activity_main file doesn't have any compilations errors (Red marks) before you follow these steps.

First remove the line

import com.example.newp.R;

Still error persists, then make a single line comment to setContenView();

//setContentView(R.layout.activity_main);

Now clean the project from menu Project -> clean.

Remove comment line to setContentView().

Now check that you don't have any errors.

If problem persists, restart your eclipse.

Aswin
  • 1,154
  • 1
  • 11
  • 29
0

Check your res folder. If you have resources errors, than fix them and after that try Project->Clean.

yyunikov
  • 5,719
  • 2
  • 43
  • 78
0

I found a pretty handy guide that provides a lot of possible solutions to the R problems.

Jason Crosby
  • 3,533
  • 4
  • 28
  • 49