[英]How work the jar located inside the /libs subfolder of an aar?
Inside some aar
archives their is a libs
subfolder with some .jar
in it.在一些
aar
档案中,它们是一个libs
子文件夹,其中包含一些.jar
。 What the purpose of those jars?这些罐子的用途是什么? why they are not merged in the classes.jar?
为什么它们没有合并到 classes.jar 中? If I add the
aar
as a dependency of my android project, how the jar inside the libs
subfolder will be included in the final apk
?如果我将
aar
添加为我的 android 项目的依赖项,那么libs
子文件夹中的 jar 将如何包含在最终的apk
中?
The JARs in the libs
directory of an AAR are dynamically linked during runtime. AAR 的
libs
目录中的 JAR 在运行时动态链接。 Exactly like the JAR files you would provide in the libs
directory of your project.与您将在项目的
libs
目录中提供的 JAR 文件完全一样。
As you may note, the content of an AAR file is similar to the structure of an Android application project -- at minimum a manifest file, and further (optional) files and directories.您可能会注意到,AAR 文件的内容类似于 Android 应用程序项目的结构——至少是一个清单文件,以及更多(可选)文件和目录。 You may find resources (
res
and/or assets
), libraries (native ones in lib
, JARs in libs
) and so on.您可能会找到资源(
res
和/或assets
)、库(本地库在lib
中,JAR 在libs
中)等等。 Not every AAR files does even contain a classes.jar
, as some of theme are only intended to deliver additional res
content.并非每个 AAR 文件甚至都包含
classes.jar
,因为一些主题仅用于提供额外的res
内容。 That can often be found in compat-AARs.这通常可以在 compat-AAR 中找到。
Basically, during the APK building process one simple thing is made with an AAR file which has been included into the project.基本上,在 APK 构建过程中,使用包含在项目中的 AAR 文件做一件简单的事情。 It will be unzipped and its files and directories are merged -- at least logically, not necessarily physically -- with their corresponding counterparts in the project.
它将被解压并且它的文件和目录被合并——至少在逻辑上,不一定在物理上——与它们在项目中的对应部分合并。 So in your case, the JAR files in the AAR's
libs
directory are added to the libs
directory of your project, where you keep the Java libraries you want to link dynamically during application runtime.因此,在您的情况下,AAR 的
libs
目录中的 JAR 文件被添加到项目的libs
目录中,您可以在其中保存要在应用程序运行时动态链接的 Java 库。
Apart from that the APK building process runs as usual.除此之外,APK 构建过程照常运行。
In short -- An AAR is a ZIP whose content is merged into the project it was added to.简而言之——AAR 是一个 ZIP,其内容被合并到它被添加到的项目中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.