如何将android库项目转换为包含所有类和资源的.jar文件?

时间:2014-12-08 09:03:24

标签: android eclipse jar

我需要将android项目转换为包含所有类和资源的.jar文件。我们可以选择这样做吗?我尝试转换为android库项目,然后转换为jar文件。它总是显示空指针异常。

1 个答案:

答案 0 :(得分:1)

如果您的库是纯Java代码,没有资源,您可以使用.class文件创建JAR,就像使用常规Java一样:

1. Right click the project.
2. Export --> Java --> JAR file.
3. Tick the files to include and name the jar, click "Next".

有关java的详细信息,请参阅this。 对于Android,请参阅此ans

You cannot export the library project to a self-contained JAR file, as you would do for
a true library. Instead, you must compile the library indirectly, by referencing
the library in the dependent application and building that application.

修改
使用图书馆的drawables,请参阅this