类型R已经定义了错误。

时间:2022-11-06 18:58:33

类型R已经定义了错误。 How do I fix this? I already tried removing the R.java and cleaning the project via eclipse, but it doesn't help.

我怎么解决这个问题?我已经试过去掉R。java和通过eclipse清理项目,但是没有帮助。

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-android/,但到目前为止,很难让事情顺利进行。

6 个解决方案

#1


45  

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"

" R类型已经被定义"

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.

如果您试图构建Funambol Android Sync客户端,那么您将在Eclipse中得到这样的消息。原因是您已经检查了两个试图生成相同类的构建器。您只需要从Project->属性->构建器中取消对Java-Builder的检查。然后应用程序甚至在模拟器中运行良好。

#2


8  

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

删除R。java来自src文件夹并重新构建项目。在此过程中,该文件将自动被拒绝。

#3


7  

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. 点击右边的项目点击属性。
  3. Project->Properties->Builders.
  4. 项目- >属性- >建筑商。
  5. unckeck java Builder
  6. unckeck java构建器
  7. delete file R.java
  8. 删除文件参数

#4


3  

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”。罐子里有R。类定义在与您相同的包结构中。

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

这是一个指向R的链接。来自谷歌代码项目的java。注意,您使用的是相同的包:http://code.google.com/p/apps-android/source/browse/trunk/photostream/src/android/photostream/r .java?

#5


2  

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 builder是我的问题,但是当我做代码更新时,它们并没有反映在运行的应用程序中,在我的例子中,有一个R。java在我的源代码中删除了,这解决了我的问题。

#6


1  

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-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

这是一样的,所以请注意额外的空间。谢谢你!

#1


45  

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"

" R类型已经被定义"

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.

如果您试图构建Funambol Android Sync客户端,那么您将在Eclipse中得到这样的消息。原因是您已经检查了两个试图生成相同类的构建器。您只需要从Project->属性->构建器中取消对Java-Builder的检查。然后应用程序甚至在模拟器中运行良好。

#2


8  

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

删除R。java来自src文件夹并重新构建项目。在此过程中,该文件将自动被拒绝。

#3


7  

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. 点击右边的项目点击属性。
  3. Project->Properties->Builders.
  4. 项目- >属性- >建筑商。
  5. unckeck java Builder
  6. unckeck java构建器
  7. delete file R.java
  8. 删除文件参数

#4


3  

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”。罐子里有R。类定义在与您相同的包结构中。

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

这是一个指向R的链接。来自谷歌代码项目的java。注意,您使用的是相同的包:http://code.google.com/p/apps-android/source/browse/trunk/photostream/src/android/photostream/r .java?

#5


2  

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 builder是我的问题,但是当我做代码更新时,它们并没有反映在运行的应用程序中,在我的例子中,有一个R。java在我的源代码中删除了,这解决了我的问题。

#6


1  

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-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

这是一样的,所以请注意额外的空间。谢谢你!