0

I have hard time in including an Android Project Library in my Android Project. Basically, my library has yet only a simple class file, but the app project can't resolved the said class. I therefore can't compile and so can't find any error message.

I did as stated by official doc: Create a project, convert it in a library by checking "isLibrary" in project Properties->Android; went in the app project and in Properties->Android, add the said library.

Tried a lot of things: Clean/rebuild projects; Restart Eclipse; Reboot computer (more then once, to say my level of despair!) Delete / re-import my Library; Put App and Library in the same root folder I put in my manifest: (changed true for false, did nothing)

The thing is supposed to be so straightforward that I have no clue what to do when it doesn't work and no error message is thrown. I'll take any advice, from ultra-specific to meta-general!

Thanks in advance.

4

2 回答 2

2

想出了我的问题的答案。对不起,如果它在你的脑海中引发“Duh”反应......

当我将项目创建为库时,我看到我的包不是 com.mycompany.mypackagelib,而是在 Eclipse 中写为“(默认包)”。我试图纠正它,我实际上重命名了我的包,但 Eclipse 拒绝,说 com.mycompany.mypackagelib 已经是名称(例如清单中所述)。所以我在.java文件中强制它,写“package com.mycompany.mypackagelib”,但是得到一个错误,说它应该是包“”。我进入了快速修复子菜单,它建议我将其移至 com.mycompany.mypackagelib。然后宾果。希望这对某人有所帮助。

于 2013-06-05T13:58:21.990 回答
1

Recently, Google updated its tools and it introduced some strange behaviour when using library projects. I'm not sure you're dealing with the same problem, but try this:

  • right click on your library project, choose Properties
  • in the menu on the left, click on Java Build Path
  • now click ont the Order and export tab

make sure "Android private libraries" and "Android dependencies" are checked. Do the same for your application project.

After these steps, clean both projects and maybe your problem is fixed ;-)

good luck!

于 2013-06-04T18:04:41.520 回答