8

I'm switching my dev computer from windows 7 to a mac. I saved my old workspace and transferred the whole file to mac. Eclipse has found the workspace, but I'm getting the "R cannot be resolved.." error. I've tried the usual suggestions: Clean, build automatically, ctrl+shift+O, etc but it's not working. Is this right way to transfer workspaces? Thanks

Broo
  • 859
  • 4
  • 11
  • 21
  • I'm not sure what you mean with a saving the workspace to a file, but I can tell you what had worked for me often across platforms (win/linux in this case): Just copy the entire workspace folder over and direct eclipse to the copied folder. –  Aug 25 '11 at 12:11
  • "R" is an auto-generated class from the Android-Platform –  Aug 25 '11 at 12:12
  • Yes, R the auto-generated class in android. – Broo Aug 25 '11 at 12:14
  • Sorry, I just copied the workspace folder onto my mac. – Broo Aug 25 '11 at 12:15
  • 1
    Found it. It was trying to build against an earlier api that it says it doesnt have (it does), sorted that then had to remove all the import android.R lines and unused libraries, phew!! – Broo Aug 25 '11 at 12:34

4 Answers4

1

I had this problem as well, it turned out that I had inadvertently deleted the “app_name” string resource from the strings.xml file, which was causing a silent error. Once I added it back, the R class was generated successfully and everything was back up and running

ashwini
  • 11
  • 1
1

If you have copied the workspace folder, have you checked that the project is still pointing to the android SDK? I would imagine it is in a different location on the mac than the win 7 pc.

Also, if you've done ctrl+shift+o in eclipse then it may have tried to add an import for R which will stop it from using the autogenerated R file when building.

I've had the same problem quite a few times due to using 3 computers for android dev. Often have to open and close projects, and clean builds to get it working.

Adam
  • 61
  • 3
1

A much more extensive discussion of this error message and solutions, from '09: R cannot be resolved - Android error

My problem was fixed by finding an XML error in Manifest.xml regarding the package name, as hinted at by Android - R cannot be resolved to a variable

Community
  • 1
  • 1
Walter K
  • 1,474
  • 1
  • 14
  • 24
0

R.java file usually doesn't get generated if you have any problems with your resources. Pay attention to the resources such as layouts, values etc. to find any errors there. When you resolve all the errors the R file will build successfully. Hope this helps.

Egor
  • 39,695
  • 10
  • 113
  • 130
  • Used to have that problem in galileo, when an error in an xml file caused the whole R class to error. Hopefully they've fixed it in Indigo, thanks – Broo Aug 25 '11 at 12:40