我有两个R生成的类。我怎么解决?

时间:2023-01-18 11:23:51

I originally had my app all in one project. I decided to rearrange things so I could have multiple projects referencing the same code, so I moved a package to a plain java library, and some others to an android library.

我最初在一个项目中有我的应用。我决定重新安排一些东西,这样我就可以有多个项目引用相同的代码,所以我将一个包移动到一个普通的java库,而其他一些则移动到一个android库。

The main app originally had two packages;

主应用最初有两个包;

com.stuff           // standard java stuff
com.stuff.android   // android specific stuff

When I rearranged, I moved all the com.stuff package to the plain java project and some of the com.stuff.android classes to an android library. The main app now references both.

当我重新整理时,我移动了所有的com。简单java项目和com.stuff包。android类到android库。主应用程序现在同时引用了这两个。

Now my main app is generating two R classes! One in com.stuff and one in com.stuff.android. The android library has it's own R in com.stuff.android. Neither the android library or app have classes in com.stuff anymore. Only the plain java package has com.stuff package classes.

现在我的主要应用是生成两个R类!com。一件一件,一件一件。android库在com.stuff.android中有自己的R。android库和应用程序都没有com类。的东西了。只有普通java包有com。包类的东西。

Both R classes seem to have the same stuff, most of the time. But sometimes weird things happen, and I need to clean all the projects and rebuild to get it to work again, and it's just annoying.

两个R类在大多数时候似乎都有相同的东西。但有时会发生奇怪的事情,我需要清理所有的项目,重新构建,让它重新工作,这很烦人。

Why is it doing this? How do I fix it?

为什么会这样?我怎么修理它?

I am also using subclipse, so maybe it's interfering somehow with all the refactoring

我也在使用subclipse,所以它可能会以某种方式干扰所有重构

1 个解决方案

#1


2  

Aha! Found it myself... how come articulating the problem seems to spur new ideas on where to look.

啊哈!发现自己……为什么这个问题看起来会激发新的想法呢?

  1. The manifest of the application still had package="com.stuff" instead of com.stuff.android
  2. 应用程序的清单仍然有package="com "。东西”而不是com.stuff.android
  3. Some of the layouts still had a namespace reference to com.stuff.
  4. 有些布局仍然对com.stuff有名称空间引用。

Fixing those two solved the issue.

解决了这两个问题。

Edit: And then I thought about this: Changing the package name of an upgraded Android application

编辑:然后我想到了这个:改变一个升级的Android应用程序的包名。

Oops.... so looked into my android library, and it was using com.stuff.android in the manifest... So I guess the app was trying to use both? Changed everything back to com.stuff, and now I have one R in com.stuff. Phew!

哎呀....我查看了我的android库,它使用com.stuff。android在manifest……所以我猜这个应用会同时使用这两种功能?把一切都改成com。东西,现在我有一个R在。东西。唷!

#1


2  

Aha! Found it myself... how come articulating the problem seems to spur new ideas on where to look.

啊哈!发现自己……为什么这个问题看起来会激发新的想法呢?

  1. The manifest of the application still had package="com.stuff" instead of com.stuff.android
  2. 应用程序的清单仍然有package="com "。东西”而不是com.stuff.android
  3. Some of the layouts still had a namespace reference to com.stuff.
  4. 有些布局仍然对com.stuff有名称空间引用。

Fixing those two solved the issue.

解决了这两个问题。

Edit: And then I thought about this: Changing the package name of an upgraded Android application

编辑:然后我想到了这个:改变一个升级的Android应用程序的包名。

Oops.... so looked into my android library, and it was using com.stuff.android in the manifest... So I guess the app was trying to use both? Changed everything back to com.stuff, and now I have one R in com.stuff. Phew!

哎呀....我查看了我的android库,它使用com.stuff。android在manifest……所以我猜这个应用会同时使用这两种功能?把一切都改成com。东西,现在我有一个R在。东西。唷!