简体   繁体   English

为什么我的R文件丢失了? 在一个全新的项目上。

[英]Why is my R file missing? on a brand new project.

I know this has been asked before, before you thumb down read my full post, then feel free to thumb down, I'm sure I have a few coming. 我知道有人问过这个问题,在您否定阅读本人的完整文章之前,请随时对此表示怀疑,我敢肯定我会提出一些建议。 ;) ;)

So I just started a new Android project, I've made several in the past, but this time from the start the R file was not found and I get "R cannot be Resolved to a variable". 因此,我刚刚启动了一个新的Android项目,过去做过几次,但是这次从一开始就没有找到R文件,并且得到了“ R无法解析为变量”。

Figuring this is most likely a common problem I checked StackOverflow to see what if others have solved the problem, and lots have, but almost all have to do with something the user did with renaming something. 弄清楚这很可能是一个常见问题,我检查了StackOverflow来看看其他人是否解决了该问题,并且有很多问题,但几乎所有都与用户重命名某些事情有关。

My problem is that I haven't even started yet and just with the code auto generated from eclipse It already shows these errors. 我的问题是我什至还没有开始使用eclipse自动生成的代码,它已经显示了这些错误。

What I've already tried. 我已经尝试过的。 1 Project-> clean before and after every other thing I tried 2 check to see if any res files had unsupported charters 3 checked for updates (SDK Eclipse ADT) 4 checked that I had Andriod build tools 5 Project properties -> build path is in correct order with everything that needs be checked. 1在我尝试过的所有其他事情之前和之后进行项目->清理2检查是否有任何res文件具有不受支持的章程3检查更新(SDK Eclipse ADT)4检查我是否拥有Andriod构建工具5项目属性->构建路径在正确的顺序以及需要检查的所有内容。 6 Package is spelled correctly in the AndroidManifest. 6套件在AndroidManifest中的拼写正确。 7 Rebuilt Project 8 Every thing suggested here - "R cannot be resolved to a variable"? 7重建项目8此处建议的所有内容- “ R不能解析为变量”?

I know this question has been asked a million times, but I can not find an answer that works for me and I'm frustrated enough to re-post a million and 1st question. 我知道这个问题已经被问了一百万遍了,但是我找不到适合我的答案,我很沮丧地重新发布了一百万个第一个问题。

If you have any solutions other than the list above let me know, I will continue searching the interwebs for more solutions in the mean time. 如果您有除上述列表之外的其他解决方案,请告知我,与此同时,我将继续在Internet上搜索更多解决方案。

In my experience the most common cause of the R file not being generated is an error in your source code. 以我的经验,未生成R文件的最常见原因是源代码中的错误。 Usually in your layout XML files. 通常在您的布局XML文件中。 Make sure that you do not have any errors in any of the XML files. 确保在任何XML文件中都没有任何错误。

You just make one R.java file manually under gen folder under your package. 您只需在包下的gen文件夹下手动创建一个R.java文件。 Now try to compile. 现在尝试编译。 I expect to automatically R.java will be modified. 我希望R.java会自动被修改。 I had the same problem once. 我曾经有过同样的问题。

"R" in android is a class TODO auto-generated, this means that everytime you build your project R.java is compiled again. android中的“ R”是TODO自动生成的类,这意味着每次构建项目R.java时都会再次对其进行编译。 I think that probably you have some problem with your SDK. 我认为您的SDK可能存在一些问题。 I advise you to control Manager SDK if you are using Eclipse or tryng to launch ant from your terminal in such a way to verify that Ant tool is installed on your machine, if no the R.java cannot be generated. 如果您正在使用Eclipse或tryng从终端启动ant ,我建议您控制Manager SDK,如果无法生成R.java,则可以验证您的计算机上是否已安装Ant工具。

您可以创建一个新项目,如果您还没有编辑过这个项目,那将不会有太多工作。

Please try changing your workspace on starting eclipse. 请在启动Eclipse时尝试更改工作区。 And create a new project and attempt. 并创建一个新项目并尝试。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 我的JLabel刷新方式有所不同,具体取决于Eclipse项目。 为什么? - My JLabel refresh differently, depending on the Eclipse project. Why? 我所有的线程都在我的 WebScraper 项目中等待。 有人能告诉我为什么吗? - All my threads are waiting in my WebScraper project. Can someone tell me why? 创建新的Maven项目时显示错误。 - Error shown on creating a new maven project. 全新的Eclipse插件项目充满了错误 - Brand new Eclipse plugin project riddled with errors SLF4J 包含在我全新的 React Native 项目中,它导致应用程序重启时出错 - SLF4J is included in my brand new react native project and it is causing an error on app reboot 你好。 我的项目中有一个错误。 我不知道为什么 Logcat 对我的 retrofit object 发誓 - Hi! I have a bug in my project. I don't know why Logcat swears at my retrofit object 为什么我的Java文件看不到R文件中的新元素? - Why does my java file not see the new elements in my R file? 一行代码破坏了我的项目。 如何维修? - A single line of code destroyed my project. How to repair? R.Java在我的项目中缺失,不会再生 - R.Java is missing from my project and will not regenerate 为什么在清理项目时Eclipse会不断删除我的R文件? - Why does Eclipse continually delete my R file when cleaning the project?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM