Referenced Java Project Compiled Update Doesn't Update Android Library Project

核能气质少年 提交于 2019-12-24 00:46:37

问题


I have an Android Project(A) that's my main application, it references an Android library Project(B). The Library Project references a standard Java Project(C) which is my standard library for many Java and Android projects. I will reference these three projects as A,B,and C.

My issue is if I make a change to the C project it will auto compile but B doesn't compile hence A doesn't see the changes. The only way to do this is to clean B manually. Is there a way in Eclipse to force B to re-compile when C is compiled?

Using Eclipse 3.6.2 with ADT 14 and SDK 14.


回答1:


I've also had this problem with ADT 14. In my case, I have less indirection (project A is the PLAIN java library (not an android library), project B is the android app).

What was really fun was that I had two project "B" (two android apps), and one was working. The other was an exact copy (with minor changes for a beta release), including a copy of the project files.

It compiled fine, but failed to package the library files on the beta version.

I removed the project (not deleting the files) and re-added it. Then, I also reconfigured the app's build path and removed the java library. Then I reconfigured it again and re-added it.

Clean/Build and it started packaging them correctly again.

I also did the build order trick mentioned earlier...it didn't help by itself, but may have contributed to the later eclipse refresh working (made sure library project built before others).




回答2:


I had the exact same issue with ADT 20. Combing the comments with the accepted answer, I found that moving the library project to be the first in Project Properties -> Java Build Path -> Order and Export solved it.




回答3:


I tried the accepted answer with project B (android) referencing project A (regular java). After removing and re-adding project B to the workspace, removing project A from project B's required projects, re-adding project B, ticking project B in project A's order/export and moving it to the top and finally clean/build all, my problem was not resolved. After the clean and build, all was up to date. But when IU changed anything in A, the changes were not visible in B.

My solution:

In the build path of the android project: - select source tab - click Link source - select the java project's src folder. Name it linkedLibrarySource - apply, clean build - success

This solution is less than ideal, and I advice to try other solutions first.

There is a disadvantage: eclipse now adds a linkedLibrarySource folder to your android project. It contains the same files as the src folder of your lib. Eclipse sees them as different. This means that you can edit the same file on two locations, causing conflicts. So don't touch linkedLibrarySource!

I use ADT 20



来源:https://stackoverflow.com/questions/7909175/referenced-java-project-compiled-update-doesnt-update-android-library-project

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!