开发者

I have two R generated classes. How do I fix?

开发者 https://www.devze.com 2023-04-06 19:21 出处:网络
I originally had my app all in one project.I decided to rearrange thing开发者_StackOverflows so I could have multiple projects referencing the same code, so I moved a package to a plain java library,

I originally had my app all in one project. I decided to rearrange thing开发者_StackOverflows 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.

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.

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.

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.

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


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. Some of the layouts still had a namespace reference to com.stuff.

Fixing those two solved the issue.

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

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!

0

精彩评论

暂无评论...
验证码 换一张
取 消