Android ADT version 22, R.java files not generated

2019-01-15 12:14发布

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?

11条回答
我欲成王,谁敢阻挡
2楼-- · 2019-01-15 12:31

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.

查看更多
走好不送
3楼-- · 2019-01-15 12:34
  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

查看更多
啃猪蹄的小仙女
4楼-- · 2019-01-15 12:37

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.

查看更多
女痞
5楼-- · 2019-01-15 12:41

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!

查看更多
男人必须洒脱
6楼-- · 2019-01-15 12:43

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.

查看更多
\"骚年 ilove
7楼-- · 2019-01-15 12:44

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.

查看更多
登录 后发表回答