Adding Android library project to Eclipse build path?

[亡魂溺海] 提交于 2020-01-29 21:19:48

问题


I have a multi module Android Maven project which consists of several projects and an Android library project (baselib) where I run non Android based JUnit tests.

This works as long as I run the test by Maven. When I run the baselib JUnit tests by Eclipse with Run->As JUnit test, I don't get the current version. That means that changes in the JUnit test have no effect until I make a Maven build.

I thought about adding the bin folder to the Eclipse build path, but I get an error message in Eclipse:

Cannot nest output folder ...baselib-TRUNK/bin/classes inside ...baselib-TRUNK/bin

That's somehow clear. So I thought about adding the jar itself to the build path. I added it once as external jar, then once as jar. But I still don't get the current version of the code although the timestamp of the jar has the current version if I modify and save some code. (Build Automatically is checked in Eclipse). Output folder is recognized by Eclipse's build path configuration as .../bin/classes which is set in pom.xml. I also tried to add /bin/test-classes to build path which contains the test class itself, but still no new version of the code.

Why does this not work to get the current version and how can I solve this?


回答1:


Since the library projects are in the same workspace, we can reference the project directly. Open the preferences for your project and click on the "Android" section.

Now, you will see a window for referencing library projects.

Click the "Add..." button, select the projects you want, click "OK", and hit "Apply". Only projects that are marked as libraries can be selected and referenced in this manner. If your projects are not appearing, open their preferences and mark the "Is Library" box in this window of their preferences.

Your project will now reference these libraries, including any changes you make to them. This is better than using a jar if your libraries will be subject to change. Otherwise, you would have to remove and re-add the jar every time you make a change.



来源:https://stackoverflow.com/questions/16968153/adding-android-library-project-to-eclipse-build-path

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