gpt4 book ai didi

java - 将 android 库导出为 .jar 文件

转载 作者:行者123 更新时间:2023-12-01 11:05:08 25 4
gpt4 key购买 nike

我刚刚创建了一个 android 库模块,现在我想将其导出为 .jar 文件(就像我以前在 Eclipse 中所做的那样),这样我就可以在其他项目中使用它,只需将其链接为外部库文件。

问题是我刚刚从官方网站上读到“您无法将库模块导出到 JAR 文件”:https://developer.android.com/tools/projects/index.html

那么我该怎么做呢?我可以做类似的事情来获得相同的结果吗?

谢谢

最佳答案

您必须将其导出为 .AAR 文件。无法将 Android Studio 库导出为 .jar 文件。

<强> Android .AAR Format

看看这个:https://androidbycode.wordpress.com/2015/02/23/building-an-aar-library-in-android-studio/

Purpose of AAR: Library reuse has long been available in Java based applications through Java Archive (.jar) files. Android AAR files build upon this concept to allow you to package not only the source code but also the libraries self contained Android resources. The library can have its own manifest and resources and can also optionally provide assets, NDK built libraries, proguard configuration and even its own custom lint filters. This is all bundled into a zip archive that can be published to a repository for your team (or the world!) to get easy access from a Gradle build.

这是@alex18aa创建.AAR文件的方法:

文件 -> 新建模块 -> 导入aar/jar,然后在模块设置中添加依赖,并链接它。

关于java - 将 android 库导出为 .jar 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33043107/

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