Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Studio. Problems with R class

I've upgraded to Android Studio 0.1.6 and cannot compile my project since. I'm getting 81 errors in code wich was working perfectly fine with the previous version of the application. No code changes.

All of the errors related to the R class, examples:

java: cannot find symbol
symbol:   variable string
location: class %mypackagename%.R

And

java: cannot find symbol
symbol:   variable id
location: class %mypackagename%.R

I've tried to remove the content of the "gen" folder a few times, it get's regenerated, but it doesn't fix the problem.

I've looked for a solution all over the Internet, but can't find anybody with a similar problem. Some people having problems importing their projects to Android Studio, but my project was originality created in intellij idea and I keep working on it with Android Studio.

BTW, Intellij IDEA can compile and run project still, but I got used to Android Studio already.

I'm working on a MAC OS 10.8 if it makes any difference.

Your help is much appreciated.

UPDATE 1: I've checked this thread, both gen and src selected as sources and I don't have "import android.r" anywhere in the code

like image 880
Vlad Spreys Avatar asked Jun 22 '13 10:06

Vlad Spreys


People also ask

How do I fix my android R?

"R cannot be resolved" arise only if there is a problem with some of your resource files. So the best and effective way is delete the last done xml or drawable in res file. and then again start from there according to android coding norms.

What is the R class in Android Studio?

R class is generated by Android tools from your resources before compiling your code. It contains assigned numeric constant for each resource that you can refer in your project. For example, you have XML resource file that contains about_button .

Where is the R class in Android Studio?

R. java is the generated file by ADT or Android studio. It will be located under app\build\generated\source\r directory.

What is R Java class used for in Android?

Android R. java is an auto-generated file by AAPT (Android Asset Packaging Tool) that contains resource IDs for all the resources of res/directory. If you create any component in the activity_main. xml file, id for the corresponding component is automatically created in this file.


2 Answers

This is a known bug in 0.1.6. Google has suggested turning off external builds in Preferences > compiler as a temporary fix

@simon this guy is supposed to be able to resolve a known bug in android studio that google hasn't been able to completely track down yet? If you're going to negatively comment on something like this please do your research first.

http://code.google.com/p/android/issues/detail?id=56843&colspec=ID%20Type%20Status%20Owner%20Summary%20Stars

like image 141
Adam Johns Avatar answered Sep 28 '22 02:09

Adam Johns


its a bug. But menu Build > Rebuild Project arranges everything.

like image 29
Celio Marcos Avatar answered Sep 28 '22 02:09

Celio Marcos