暴露的" Android的图书​​馆项目和QUOT;公司包括罐子项目,其中引用它们 [英] Expose an "Android Library Project"'s included jars to Projects which reference them

查看:215
本文介绍了暴露的" Android的图书​​馆项目和QUOT;公司包括罐子项目,其中引用它们的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

一个Android版的新功能是创建一个库的能力项目

One of the newer functions of Android is the ability to create a Library Project.

这是伟大的单元测试并在您可能正在开发许多应用程序共享常见功能,但我似乎对在执行中的错误已经迷迷糊糊。

This is great for unit testing and sharing common functionality across many apps you may be developing, but I seem to have stumbled upon a bug in their implementation.

当你有以下情况:

- LibraryProject 包含 LibraryProject /库/文件夹/ lib.jar 在它的构建路径

-LibraryProject contains LibraryProject/libs/folder/lib.jar in it's build path.

- ReferencingProject 引用 LibraryProject

ReferencingProject 您不必在 lib.jar 获得任何东西(如常量的用来沟通与在图书馆项目)。

From ReferencingProject you don't have access to anything inside lib.jar (Such as constant's used to communicate with methods in the Library Project).

一个解决方案是包括lib.jar作为引用项目外部库,但这种方式开始由具有资源可能创建多个手动添加引用一个自包含库项目否定你获得的好处库项目的开发过程中移动/改变(更不用提会造成一些pretty混淆错误)。

A solution to this is to include "lib.jar" as an external library in the referencing project but this approach begins to negate the benefits you gain from having a self contained Library Project by creating multiple manually added references to resources which could move/change during the development of the library project (not to mention cause some pretty confusing errors).

有没有什么办法可以暴露一个包含库类引用的项目,而无需手动引用它们作为外部罐子?

Is there any way to expose an included libs classes to the referencing project without having to manually reference them as external jars?

推荐答案

由于@Selvin说:

As @Selvin says,

在图书馆计划,您可以指定要标记为出口在窗口和使用提出了哪些库:项目属性=> Java构建路径=>为了和导出。从这个例子中,你会检查库/文件夹/ lib.jar

In the Library Project you can specify which libraries you want to mark as "exported" in the window brought up by using: Project properties => Java Build Path => Order and Export. From this example you would check libs/folder/lib.jar.

清洁并建立图书馆项目和现在的出口库包含在生产罐。

Clean and build the Library Project and the "exported" libraries are now included in the produced jar.

修改

这是升级到ADT 17症状 - (Android的团队​​:或许把一些警告您发布说明当更新现有的休息架构)

This is a symptom of upgrading to ADT 17 - (Android Team: Perhaps put a few warnings on your release notes when an update breaks existing architectures?)

http://tool​​s.android.com/recent/dealingwithdependenciesinandroidprojects

如果您不希望将库添加到排序和导出然后把当地的罐子在 /库/ 基本文件夹会自动添加到Android的依赖关系,这是从共享库中创建的JAR出口。

If you don't want to add the library to the "Order and Export" then placing local jar's in /libs/ base folder will automatically add it to "Android Dependencies" which are exported in the jar created from your shared library.

EDIT2

最近ADT升级会对您也可手动选择Android的依赖关系为出口在您的Java构建路径。再次,警告将是不错的。

Recent ADT upgrade would have you also manually select "Android Dependencies" as "Exported" in your Java Build Path. Again, warning would be nice.

这篇关于暴露的" Android的图书​​馆项目和QUOT;公司包括罐子项目,其中引用它们的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆