-5

I just had a working app turn into a broken one. When I call any findViewById, the app cannot browse R properly and says R cannot be resovled to variable. So none of my drawables and code can be read. It says to import R but then it gets even further into the rabbit hole of fustration.

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

edit: I had an error within my strings.xml. IT now works. Thanks to the helpful comments.

Jayizzle
  • 532
  • 1
  • 6
  • 24
  • Are you using Eclipse or Android Studio? What package is your activity class in? What is the package for your project? – Code-Apprentice Jul 25 '14 at 22:59
  • Have you ever visited Microsoft's support forums? First answer is always the same: "Have you tried turning it off and on again"? Same here, what happens when you clean project? Check your layout files, maybe you added a comment, which breaks xml? – Marius Jul 25 '14 at 23:03
  • Im using Eclipse ADT. My package is in com.jakegosskuehn.couchto5k. – Jayizzle Jul 25 '14 at 23:04
  • possible duplicate of [R cannot be resolved - Android error](http://stackoverflow.com/questions/885009/r-cannot-be-resolved-android-error) – ben75 Jul 25 '14 at 23:05

2 Answers2

1

You should fix any syntax errors in your main layout first.

user3219446
  • 117
  • 1
  • 11
1

Most probable cause is an error in one of your layouts. If the resource compiler can't compile the resources, it doesn't generate the file defining R, so suddenly R becomes unresolvable.

Look through your layouts for something wrong. It will probably be the change you made just before it all went wrong.

C B J
  • 1,838
  • 16
  • 22