开发者

Does an Android library project also export its external libraries?

开发者 https://www.devze.com 2023-02-16 14:27 出处:网络
I\'m developing a software layer that I would like to reuse several time for building my Android applications. Basically I want that, once installed, the software layer any other apps can use it (like

I'm developing a software layer that I would like to reuse several time for building my Android applications. Basically I want that, once installed, the software layer any other apps can use it (like a system library).

I was wondering what is the best solution for doing this, when I found that recently Android supports library projects (http://developer.android.com/guide/developing/projects/projects-eclipse.html#SettingUpLibraryProject).

So I decided to create my software layer as a library project, making the code it contains re-usable by the other applications I want to realize.

My softwar开发者_如何学编程e layer depends on a set of external jar, which are correctly located in the lib folder of the library project.

The problem is that when I create a new project referencing the library project I'm not able to see the classes defined into the external jars of the library project: i.e. it seems that they are not part of the classpath.

So when referring to a library project is possible to re-use only the source code defined there? If my library project have some other libraries I have to import these libraries also in the other ones (I want to avoid this!)?

I'm also interested to know if there are other ways for doing this, but searching around I haven't found other ways for realizing Android libraries/shared code.

Thanks.


Android library projects definitely incorporate any JARs you have in the library project's libs/ directory. However, if you are using Eclipse, you probably have to somehow manually add those to your build path of the host project (the one reusing the library).


Ok I finally figured out that for solving this is sufficient to add the jars to the host project build-path (no need to re-import them, you can just choose the path from the library project). However it is weird that they are not automatically exported in the host project classpath.

0

精彩评论

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