23

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 using the (ctrl + space) to get suggestions for setContentView, the code is not typed in. Upon looking at the error log, it shows that there was an "Unhandled event loop exception". The plug-in involved is the org.eclipse.ui.

Also, whenever I create a new Hello World project, the gen folder is empty. After a few hours, I tried the android studio. But I didn't like it there. Then, when I went back to Eclipse, there was an update for SDK platform tools and build tools. I updated them but I still get the errors.

I tried cleaning the project but no luck. What seems to be the problem?

DirkJan
  • 581
  • 2
  • 7
  • 22

11 Answers11

18

I had the same problem just solved it.

check:Java/Eclipse - No more R file ever

More info:https://groups.google.com/forum/?fromgroups=#!topic/android-developers/rCaeT3qckoE%5B1-25-false%5D

Community
  • 1
  • 1
Rany Ishak
  • 2,008
  • 2
  • 19
  • 19
  • I have updated the platform tools and build tools. The problem persists. – DirkJan May 16 '13 at 11:16
  • Do you get the unhandled event loop exception prior to updating the build tools and platform tools? – DirkJan May 16 '13 at 11:17
  • The plugin org.eclipse.ui is causing the unhandled event loop exception. There seems to be no folder named exactly 'org.eclipse.ui'. What I can see is a folder named 'org.eclipse.ui.intro.universal_3.2.600.v20120912-155524'. – DirkJan May 16 '13 at 11:26
  • Miraculously, the new project I made has the R.java file in it. I don't know what happened. Previously, I updated my SDK tools to r22. But new projects don't get the files in the gen folder. But, after some time, the files now appear. – DirkJan May 16 '13 at 11:32
  • Maybe you needed some restarts :) – Rany Ishak May 16 '13 at 11:36
  • I had to restart (again) after updating the SDK build-tools. Final resolution for me was: update SDK, update Eclipse, restart, update SDK, restart. – Groxx May 17 '13 at 01:38
2
  1. Update Android SDK Tools and Android SDK Platform-tools and Android SDK Build-tools from Android SDK Manager

  2. Add abover dir to your ENV $PATH

Crossle Song
  • 10,104
  • 2
  • 29
  • 38
1

Not enough credits (yet :-) ) to vote up or comment directly on Rany A. Ishak's answer, but after one day lost trying to fix these silly problems, I'm very confident I've found the right solution...I'm installing Android SDK Build-tools right now, I'll get back soon on this!

Andre
  • 489
  • 1
  • 6
  • 17
  • 2
    @Rany A. Ishak Thanks a lot for your answer!!! I think it is useful for other people having the same problems to share the result I got, so I can confirm that for me this was the right way to solve the problem. Anyway I'm sure that when I upgraded to **Android SDK Tools r22**, the **Android SDK Build-tools** was not in the package list! I find this very weird since upgrading only the **Android SDK Tools** led me to big troubles! – Andre May 23 '13 at 08:45
  • After you install the new version of the Android SDK tools, rev 22, you should close and re-open the SDK Manager. Then the Build Tools will be there for download! – Ena May 24 '13 at 13:22
  • yes, that's what I did, but it was not that straightforward! Why not to provide both the downloads together if downloading just one of them can cause really annoying problems?! – Andre May 24 '13 at 13:40
1

The solution for this is, open "Android SDK Manager". Download "Android SDK build tools". Then for safety, restart your eclipse. That's it. Back to normal. All apps start building.

Yerram Naveen
  • 286
  • 5
  • 16
0

Android SDK now has a special package: Build Tools. It was not present in earlier SDK versions, and seems like it MUST be installed in order to generate those R files. It is now the one package that does that stuff. (And probably everything else regarding building for Android). So, if you not have that installed (and you will likely not have if you just upgraded the SDK), it's like missing a compiler - you can't ever expect your code to be compiled if there is no compiler.

Dexter
  • 166
  • 1
  • 8
0

I had the same exact problem after updating to SDK 22. There seems to be an issue in the Android SDK update process that the process needed to run twice to update the SDK Tools completely. Make sure you check the SDK manager a few times by closing and re-opening the SDK manager (not Eclipse) to load the new updates. Then restart eclipse and check the SDK manager again. Make sure all items are updated. Then clean your projects and R.java will get created again.

Bms270
  • 1,586
  • 15
  • 18
0

In Eclipse, go to Project menu,there is an option build automatically, click it. That would help you build the R.java file everytime modifications are made in your project. The Clean option is also there under Project. It will help you.

Palanichamy
  • 141
  • 2
  • 9
0

I tried the following. Let the application name be "My First Application". Then the name of the package should be com.xx.myfirstapplication.yy. Make sure that you add a yy after the application name in the package field while creating the application. Hope it helps.

Bhasker
  • 195
  • 2
  • 7
0

The Same problem happened to me also,

1.Check that Android SDK Build-tools is installed. Window->Android SDK Manager->Tools->Android SDK Build-tools 2.Make sure when you update the Android SDK Tools, you also update the Android SDK Platform-tools and Android ASK Build-tools. Build fails silently if they don't match.

Solution

1.Update Android SDK Tools and Android SDK Platform-tools and Android SDK Build-tools from Android SDK Manager (Window->Android SDK Manager->Tools->Android SDK Build-tools).Then restart the eclipse.

Ann
  • 727
  • 1
  • 7
  • 19
0

This is.... "Much ado about nothing"!!!

In my case there is error due to "&" inside strings.xml file(but error not shown) for declaring string for a array type. Now the problem has been solved as I changed "&" to "and".

So, please make sure that you do not have such silly use of symbols, and clean the project.

Amanda
  • 35
  • 1
  • 7
0

I had the same problem, I just removed all the errors in my source files and xml files then R.java was generated.

ali4j
  • 522
  • 3
  • 15