classes from android project library not resolved

2019-08-25 13:36发布

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.

2条回答
看我几分像从前
2楼-- · 2019-08-25 13:48

Figured out the answer to my problem. Sorry if it triggers 'Duh'-reactions in your heads...

When I created my project to be a library, I saw that my package was not com.mycompany.mypackagelib, but instead it was written "(default package)" in Eclipse. I tried to correct it, I actually renamed my package, but Eclipse was refusing, saying that com.mycompany.mypackagelib was already the name (as stated in the manifest for example). So I forced it in the .java file, writing "package com.mycompany.mypackagelib", but then getting an error saying that it should be package "". I went in the quick fix sub menu where it suggested me to move it to com.mycompany.mypackagelib. Then Bingo. Hope this helps somebody anyway.

查看更多
成全新的幸福
3楼-- · 2019-08-25 13:53

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!

查看更多
登录 后发表回答