eclipse 类型 R 已定义错误

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/5283414/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 15:57:47  来源:igfitidea点击:

Type R is already defined error

androideclipse

提问by kolslorr

enter image description hereHow do I fix this? I already tried removing the R.java and cleaning the project via eclipse, but it doesn't help.

在此处输入图片说明我该如何解决?我已经尝试通过 eclipse 删除 R.java 并清理项目,但它没有帮助。

FYI I am trying to get PhotoStream from here: http://code.google.com/p/apps-for-android/, but so far it has been very difficult to get things work.

仅供参考,我正在尝试从这里获取 PhotoStream:http: //code.google.com/p/apps-for-android/,但到目前为止,很难让事情发挥作用。

回答by kolslorr

Okay..... 5 mins later google tells me the correct answer...

好的..... 5 分钟后谷歌告诉我正确答案...

http://www.fairtec.at/en/it-blog-mainmenu-16/168-the-type-r-is-already-defined

http://www.fairtec.at/en/it-blog-mainmenu-16/168-the-type-r-is-already-defined

I just didnt search hard enough.

我只是没有足够努力地搜索。

"The type R is already defined"

That's the message you get in Eclipse if you try to build the Funambol Android Sync Client. Reason is that you have checked two Builders that try to generate the same class. You just have to uncheck the Java-Builder from Project->Properties->Builders. Then the application even works fine in the Emulator.

“类型 R 已经定义”

如果您尝试构建 Funambol Android Sync Client,这就是您在 Eclipse 中得到的消息。原因是您检查了两个试图生成相同类的构建器。您只需从 Project->Properties->Builders 中取消选中 Java-Builder。然后应用程序甚至可以在模拟器中正常工作。

回答by Moog

Delete the R.java from the src folder and rebuild the project. This file will be automatically rebuit during this process.

从 src 文件夹中删除 R.java 并重建项目。此文件将在此过程中自动重新构建。

回答by begin

http://www.fairtec.at/en/it-blog-mainmenu-16/168-the-type-r-is-already-defined

http://www.fairtec.at/en/it-blog-mainmenu-16/168-the-type-r-is-already-defined

  1. click right to project click properties
  2. Project->Properties->Builders.
  3. unckeck java Builder
  4. delete file R.java
  1. 单击右键以投影单击属性
  2. 项目-> 属性-> 构建器。
  3. 取消 Java Builder
  4. 删除文件 R.java

回答by nicholas.hauschild

You may want to change your package names. It looks like you are using a 'PhotoStream'.jar which has it's R.class defined at the same package structure as you.

您可能想要更改包名称。看起来您正在使用一个 'PhotoStream'.jar,它的 R.class 定义在与您相同的包结构中。

Here is a link to the R.java from the project on Google Code. Notice you are using the same package: http://code.google.com/p/apps-for-android/source/browse/trunk/Photostream/src/com/google/android/photostream/R.java?r=83

这是 Google Code 项目中 R.java 的链接。请注意,您使用的是相同的包:http: //code.google.com/p/apps-for-android/source/browse/trunk/Photostream/src/com/google/android/photostream/R.java?r= 83

回答by David Silva Smith

I had the same issue when I imported a project from work. Turning off the Java builder as suggested in the article you found fixed my problem, but when I made code updates they were not reflected in the running app. In my case there was an R.java in my source which I deleted and that fixed my problem.

当我从工作中导入一个项目时,我遇到了同样的问题。按照您发现的文章中的建议关闭 Java 构建器解决了我的问题,但是当我进行代码更新时,它们没有反映在正在运行的应用程序中。就我而言,我的源中有一个 R.java,我删除了它并解决了我的问题。

回答by vivek

In my case,

就我而言,

as i m not using any IDE for programming but using command line Android..

因为我没有使用任何 IDE 进行编程,而是使用命令行 Android ..

i had two xml files, one in layout and other in layout-land. i was using same id "XXX" for both but while declaring i made small mistake

我有两个 xml 文件,一个在 layout 中,另一个在 layout-land 中。我对两者都使用了相同的 ID“XXX”,但在声明我犯了一个小错误时

android:id="@+id/XXX" (in layout xml)
android:id="@+id/XXX " (in layout-land xml)

please observe extra space in second id declaration, so while creating R.java they were different and in R.java i had

请注意第二个 id 声明中的额外空间,因此在创建 R.java 时它们是不同的,而在 R.java 中我有

public static final int XXX=0x7f040046;
public static final int XXX =0x7f040045;

which are same, so please be aware of extra spaces. Thank you

这是相同的,所以请注意额外的空格。谢谢