Questions tagged [r.java-file]

R.java is a file which holds references to project resources. It is automatically generated by the Android Development Toolkit during project compilation.

R.java is auto-generated on build. Its content is based on the resource files (including layouts and preferences). If you delete it, it will be recreated, but if you create your own, you will get into trouble as the build system will not replace it.

617 questions
736
votes
99 answers

"cannot resolve symbol R" in Android Studio

In every instance in all of my classes where I reference R.id.something, the R is in red and it says "cannot resolve symbol R". Also every time there is R.layout.something it is underlined in red and says "cannot resolve method setContentView(?)".…
ez4nick
  • 9,052
  • 12
  • 33
  • 55
310
votes
64 answers

Developing for Android in Eclipse: R.java not regenerating

I've found out that my R.java is never updated, so it doesn't contain information about my new resources, so I decided to delete it and thought that Eclipse would generate a new one. But that didn't happen, and I don't have R.java now. How can I…
Aleksejs Popovs
  • 840
  • 2
  • 12
  • 18
73
votes
14 answers

Eclipse giving error, missing R.java file after recent update

I have updated my SDK and ADT to the latest version, I have also update the Eclipse to Kepler the latest one after Juno. My ADT version is 22.0. After this update when I create a new project, I'm getting error, stating R cannot be resolved to a…
Anupam
  • 3,632
  • 18
  • 53
  • 87
51
votes
4 answers

How do I add selectableItemBackground to an ImageButton programmatically?

android.R.attr.selectableItemBackground exists, but how do I add it programatically to an ImageButton? Also, how would I go about finding the answer in the documentation? It's mentioned here, but I don't see any explanation of how it's actually…
abc32112
  • 2,357
  • 8
  • 34
  • 52
44
votes
7 answers

Renaming the package that R.java is generated in

I am using eclipse and I created a test android project and the package in the "gen" folder that contains R.java is currently called com.something.test (I thought I was just testing but build my whole app on it!) This is referenced when loading the…
Bex
  • 4,738
  • 10
  • 45
  • 82
42
votes
21 answers

No generated R.java file in my project

I am doing the Notepad tutorial, exercise 2. I started by creating a new Android project and chose Create from source to import the downloaded source files for the excercise. But now I get many errors in Eclipse, and the problem is that there is no…
Jonas
  • 97,987
  • 90
  • 271
  • 355
38
votes
4 answers

What is the concept behind R.java?

In android R.java is used to provide access to resources defined in XML files. To access the resource we need to invoke findViewById() method passing in the id of the resource to be fetched. This is similar to Spring where beans are defined in a XML…
Monika Michael
  • 1,224
  • 5
  • 13
  • 24
37
votes
6 answers

How to play the audio files directly from res/raw folder?

I have multiple audio files in res/raw folder. I showing ListView that contains audio files name. I want to play the corresponding audio file when user select into the ListView. I have used setDataSource(path), but it showing error while playing.…
bharath
  • 13,880
  • 16
  • 53
  • 93
37
votes
21 answers

Error: Unable to open class file R.java

Did a fresh install of Eclipse, JDK and android-sdk. I am currently receiving this error when creating a new project [2010-09-26 16:07:56 - Test] ERROR: Unable to open class file C:\workspace\Test\gen\com\example\test\R.java: No such file or…
Croydon Dias
  • 1,768
  • 5
  • 19
  • 27
36
votes
3 answers

Android compiled resources - resources.arsc

I am trying to figure out what it mean to "compile resources". What I did in order to understand this issue: I have read many articles about the subject but didn't find a simple answer. The best one I have read was this: How does the mapping between…
ZiviMagic
  • 954
  • 2
  • 8
  • 24
27
votes
3 answers

In Android applications what is the role of "R.java"?

Android applications have an automatically generated file called "R.java". Please explain its purpose. E.g. What is contained in it? What generates it? Duplicate: What is the concept behind R.java?
pawarrohit14
  • 497
  • 1
  • 4
  • 15
22
votes
11 answers

Android ADT version 22, R.java files not generated

After upgrading to Android ADT version 22 and cleaning my project, the R.java files went missing. I can't use setViewContent(R.layout.activity_main) because the activity cannot reference to the xml layout (due to the missing R.java). Also, when…
DirkJan
  • 551
  • 2
  • 7
  • 21
20
votes
6 answers

error: androidmanifest.xml file missing --> What am i missing?

Hi I am completely new to Android programming and the question I am asking might be something very simple, but I do not have any idea about how to make it work, so kindly bear with me. I installed android-sdk and related tools from the Android…
The Dark Knight
  • 4,986
  • 10
  • 42
  • 86
18
votes
19 answers

Magic behind R.java file

Recently I have been having quite some problems with R.java file. Now I have decided to do a backup and delete the file to see what happens. Nothing happened, so I created an empty R.java file and hoped for the best. Now Eclipse seems to figure out…
LambergaR
  • 2,353
  • 4
  • 23
  • 34
16
votes
12 answers

Missing R.java file even though project cleaned

Every time in code that I have an R, I get an error R cannot be resolved to a variable. The R.java file appears to be missing. I have tried cleaning the project.
James
  • 241
  • 1
  • 3
  • 5
1
2 3
41 42