Java/Eclipse - 不再有 R 文件
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/16584015/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Java/Eclipse - No more R file ever
提问by Hymanyto
I'm on Eclipse for hours now and I didn't found a solution yet for my problem even after many searches on internet: I have no more R.java file on my projects.
我现在在 Eclipse 上呆了几个小时,即使在互联网上进行了多次搜索,我也没有找到解决我的问题的解决方案:我的项目中没有更多的 R.java 文件。
On just created or on my old projects, i don't have R file anymore and I tried so many solutions (uninstall, re-install Eclipse, clean my project, check all my XMLs, fix problem with android tool and so on ...)
在刚刚创建或在我的旧项目中,我不再有 R 文件了,我尝试了很多解决方案(卸载、重新安装 Eclipse、清理我的项目、检查我所有的 XML、使用 android 工具修复问题等等.. .)
Please someone can tell me what to do in this case?
请有人告诉我在这种情况下该怎么办?
采纳答案by Rany Ishak
Hey If you just updated to ADT Rev 22 :
嘿,如果您刚刚更新到 ADT Rev 22:
I had the problem too. There is a new component in the Tools folder called "Android SDK Build-tools"that needs to be installed.
我也有这个问题。Tools 文件夹中有一个名为“Android SDK Build-tools”的新组件需要安装。
Step 1
第1步
Open the Android SDK Manager
打开 Android SDK 管理器
Step 2
第2步
Select the newly added Build Toolsand install. (If problem stays then go to Project Properties => Java Build Path => Order and Export and checkAndroid Private Libraries, then clean and build project.
选择新添加的Build Tools并安装。(如果问题仍然存在,则转到 Project Properties => Java Build Path => Order and Export 并检查Android Private Libraries,然后清理并构建项目。
It may be necessary to repeat the process, restart the SDK Manager after the update and make sure it looks like this (all tools installed):
可能需要重复该过程,更新后重新启动 SDK Manager 并确保它看起来像这样(安装了所有工具):
More info:https://groups.google.com/forum/?fromgroups=#!topic/android-developers/rCaeT3qckoE%5B1-25-false%5D
更多信息:https: //groups.google.com/forum/?fromgroups=#!topic/android-developers/ rCaeT3qckoE%5B1-25-false%5D
回答by Jithu
Close your eclipse and after refreshing system, try to open Eclipse again. I think you are using Emulator along with the eclipse. It may be because of the low Memory problem (RAM) of your system. I used to face the same problem when I use Emulator
关闭eclipse,刷新系统后,再次尝试打开Eclipse。我认为您正在使用 Emulator 和 eclipse。这可能是因为您的系统内存不足 (RAM) 问题。我曾经在使用 Emulator 时遇到同样的问题
回答by Malachiasz
Perhaps in Project Properties -> Java Build Path -> Libraries you don't have:
也许在 Project Properties -> Java Build Path -> Libraries 你没有:
- Android 4.2.2 (or other version)
- Android Dependencies ?
- Android 4.2.2(或其他版本)
- 安卓依赖?
If so, then right click project - > Android tools -> fix android properties and see if this library showed up.
如果是这样,然后右键单击项目-> Android 工具-> 修复android 属性并查看此库是否出现。
回答by prvn
whenever there is any mistakes in any of the xmls the R goes missing when a build or clean happens so check for any xml errors in your project unless you fix it you cant get back your R on clean or build. fix the xml files and perform a clean you will have the R generated. Also check in File->properties->Builders and see if everything is checked
每当任何 xml 中有任何错误时,当构建或清理发生时,R 都会丢失,因此请检查项目中的任何 xml 错误,除非您修复它,否则您无法在清理或构建时取回 R。修复 xml 文件并执行清理,您将生成 R。还要检查 File->properties->Builders 并查看是否检查了所有内容
回答by Sofi Software LLC
I was using Eclipse Indigo and nothing I tried worked. I ended up downloading Juno SR2, reinstalling the ADT, and now everything works again.
我正在使用 Eclipse Indigo,但我尝试过的任何方法都不起作用。我最终下载了 Juno SR2,重新安装了 ADT,现在一切又正常了。
回答by Xmagic
Thank you all for saving me! I've spent the whole afternoon on search this error. Finally, my project works. By the way, I also encountered one problem which i wanna share with you:
谢谢大家救我!我整个下午都在搜索这个错误。最后,我的项目有效。顺便说一下,我也遇到了一个问题,想和大家分享一下:
After upgrading, even if my project has not errors anymore. During runtime, it seems it couldn't find the classes from the jars placed in \libs.
升级后,即使我的项目不再出错。在运行时,它似乎无法从放置在\libs的罐子中找到类。
Go into Project=>properties => Java build path= > Order and Export. Please make sure all your jars are checked.
进入 Project=>properties => Java build path=> Order and Export。请确保检查所有罐子。
回答by DrBlackstar
Reinstall everything and it'll work.. i.e. go back to Google SDK or w.e. you're using and download it. Update it to latest in SDK Manager. Go into Eclipse-Project-Prefs-Java build path-order/export TICKEVERYTHING.
重新安装一切,它会工作.. 即回到谷歌 SDK 或我们你正在使用并下载它。在 SDK Manager 中将其更新为最新版本。进入 Eclipse-Project-Prefs-Java build path-order/export TICKEVERYTHING。
回答by Hwer Aron
I have had the same kind of problem, however Rechecking all XML files in the Resources folder was helpful in my case. I found syntax error in my XML files. Cleaning and building the project again can be helpful sometimes too.
我遇到了同样的问题,但是重新检查 Resources 文件夹中的所有 XML 文件对我来说很有帮助。我在我的 XML 文件中发现了语法错误。有时,再次清理和构建项目也很有帮助。
回答by IsPha
problem: No R file get generated.
问题:没有生成 R 文件。
guess: Try cleaning project if it is old one. Else create new project with no R get generated and with no compile errors but this: no project.apk
猜测:如果它是旧的,请尝试清洁项目。否则创建没有 R 生成且没有编译错误的新项目,但是:no project.apk
In this case you have to check your SDK for the built-tools. May not be installed after updating SDK.
在这种情况下,您必须检查您的 SDK 中的内置工具。更新SDK后可能无法安装。
Thus download them if not download here, then put them under directory: SDK/built-tools folder
. Lastly, and most important, is to Run the SDK As Administrator. This guarantees refreshing SDK with all packages appearing in it.
因此,如果不在此处下载,请下载它们,然后将它们放在目录下:SDK/built-tools folder
。最后,也是最重要的是,以管理员身份运行 SDK。这保证刷新 SDK 中出现的所有包。
Install the SDK-Built-Tools or any missing packages according to the above link and you're done.
根据上面的链接安装 SDK-Built-Tools 或任何缺少的包,你就完成了。
hope this helps.
希望这可以帮助。
回答by nki
Try one thing, create a new Android Project and transfer all those files which are in the previous project. That worked for me.
尝试一件事,创建一个新的 Android 项目并传输前一个项目中的所有文件。那对我有用。