【问题标题】:How to convert android library project to .jar file with all classes and resources?如何将 android 库项目转换为包含所有类和资源的 .jar 文件?
【发布时间】:2014-12-08 09:03:24
【问题描述】:

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

【问题讨论】:

    标签: android eclipse jar


    【解决方案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.
    

    编辑:
    有关使用库的可绘制对象,请参阅this

    【讨论】:

    • 我的库包含更多的drawables和xml布局。我们可以创建jar并在其他项目中使用它吗?
    • 无法为 android 创建 jar,请参阅 stackoverflow.com/q/7973822/3879470,但是如果您将项目作为库,您可以像使用任何其他 java 项目一样使用它的类。
    猜你喜欢
    • 2014-05-22
    • 2016-05-10
    • 1970-01-01
    • 2014-07-07
    • 1970-01-01
    • 1970-01-01
    • 2012-10-14
    • 2019-03-19
    • 1970-01-01
    相关资源
    最近更新 更多