gpt4 book ai didi

android - 为 Android 开发创建库?

转载 作者:塔克拉玛干 更新时间:2023-11-03 00:54:48 25 4
gpt4 key购买 nike

我是 Android 开发的新手,但我对 Java 和 Eclipse 有一些经验。我正在寻找创建可重用库(控件、助手、“标准” Activity 等)的方法,我可以在自己的项目中使用这些库,但也可以在不公开源代码的情况下将其分发给其他开发人员。

通常,我会将类文件打包到 JAR 文件中,任何其他开发人员都可以将其添加到类路径中并使用打包后的类。

我如何使用 Android 项目做到这一点?我读过 Android 库项目,但正如文档所述,它们不能打包到 JAR 中,但会与引用库项目的项目一起编译。这意味着我还必须分发源代码。

我也读过 this post ,它询问了同样的问题,但没有提供令人满意的答案。

所以:有没有一种方法可以编译和打包一组类和其他文件(包括 XML 布局、资源和其他东西)并只分发没有任何源代码的包,以便它可以被“引用”并像任何其他开发人员的 JAR 文件?

最佳答案

I've read about Android Library Projects, but as the documentation states they can not be packaged into a JAR, but will be compiled along with the project that references the library project. This means I also have to distribute the source code.

不是真的。它确实需要一些额外的打包工作,但您可以将代码编译为 JAR 并将 JAR 分发到库项目的 libs/ 目录中。

So: Is there a way of compiling and packaging a set of classes and other files (including XML layouts, resources and stuff) and distribute only that package without any source codes so that it can be "referenced" and used like a JAR file by any other developer?

使用 Android 库项目。我有 some stuff written up here描述了更多的打包选项,以及指向遵循其中描述的约定的一些“包裹”的指针。

关于android - 为 Android 开发创建库?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3708823/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com