android.R error if import is present

I just finished debugging one of my apps because I was having issues with R.layout.

Naturally, I went to my .xml files and cleaned up a few errors and everything should have been fine, but it wasn't.

For some reason, I was still getting an error with R.layout saying that my .xml files could not be resolved to a type.

As soon as I deleted the import android.R statement, everything went away and my program compiled correctly.

To my knowledge this is the opposite of what people are saying to do in this situation. Normally they tell you to ADD that statement in to eliminate any errors, but mine was the opposite. Does anyone have any insight as to why this happens so that when this inevitably happens again I won't have to spend as much time on it?

Thanks all!


You are importing an R that doesn't contain your application's layout resources. You are instead importing the Android framework's R, thus causing a name collision. There are, however, situations in which you may need android.R. In these cases, you shouldn't import android.R, but instead explicitly use android.R.[whatever] when you need it.

Your application has it's own R which contains most of your application's resources.

android.R contains a variety of Android framework resources.

There is more information on the R class in the Android: What is R? question.

There's two R: your project one and android.R one. You were importing the wrong one

android.R should NOT be imported. It's the system's not your project's. By importing android.R, you are in fact hiding your own and that's why it can't resolve the values inside it. So as you (correctly) did, android.R should be removed from your import list. If you need to use it in your app you can use it like this :

Need Your Help

R: add letter to sequence in dataframe

r data.frame add sequence

I have a dataframe like below and i want to add 4 letter (CATG) in front of the sequences. Is that possible? Thank you All!

Using Vim, how do you use a variable to store count of patterns found?


This question was helpful for getting a count of a certain pattern in Vim, but it would be useful to me to store the count and sum the results so I can echo a concise summary.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.