-1

package com.proappangeloooo1.game1;

import com.proappangeloooo1.game1.R;

/* the error :R cannot be resolved to a variable*/

Jaap
  • 81,064
  • 34
  • 182
  • 193
tech B
  • 1
  • 1
    This is typically caused by an error in your *res* folder. For example, one of your layout XML files may be referencing a non-existent string. – pathfinderelite May 30 '15 at 17:27

1 Answers1

0

You should not explicitly import R at the top of your java code. Try making Project -> Clean...

  • 1
    "You should not import R" => of course you should, how else are you going to get access to the app resources from the java code ? – 2Dee May 30 '15 at 17:31
  • I thought you don't need to import R on Eclipse with Android development plugin. I don't need explicit import of R in my projects. Also, [this comment](http://stackoverflow.com/a/7824871/3460040) states you should not import R – Sergey Maksimenko May 30 '15 at 17:37
  • I don't know about the necessity to explicitely import R in the code, you must be right about not needing it. But the error is linked to R not being generated, not because of the import, IMO. – 2Dee May 30 '15 at 17:46
  • 1
    Edited my answer to eliminate misunderstanding – Sergey Maksimenko May 30 '15 at 17:49
  • explicitly import R class only when R class and the classes which use R are not in the same package. – Qian May 30 '15 at 18:24
  • I thought it's necessary to import the Class R I test the same code in another pc it works – tech B May 30 '15 at 18:40