本文介绍了Android中AAR、JAR、DEX、APK的区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Android系统或开发环境中,AAR、JAR、DEX、APK文件有什么区别?每个人的目的是什么?

In Android systems or development enviroments, what are the differences between AAR, JAR, DEX, and APK files? What is the purpose of each one?

AFAIK、JAR 就像 .class 文件的集合(就像在 Java 中一样).

AFAIK, JAR are just like a collection of .class files (like in Java).

AAR 是 JAR 文件 + 资源.但它的用例是什么?用于分发 Android 开发库?

AAR are JAR files + resources. But what's its usage case? To be used to distribute development libraries for Android?

APK 似乎类似于 .deb 或 .rpm 之类的软件包.这是在 Android 上安装应用程序的唯一方法吗?

APK seems to be similar to packages like .deb or .rpm. Is it the only way to install applications on Android?

DEX 文件呢?已编译的应用程序...但与 JAR 或 AAR 文件有什么区别?

What about DEX files? Compiled applications... but what's the difference with a JAR or AAR file?

此外,在为 Android 分发 .so(即本机代码)文件时,最好的方法是什么?

Moreveor, when distributing .so (i.e. native code) files for Android, what's the best way to do it?

推荐答案

JAR (Java Archive)

JAR 是一种包文件格式,设计用于在其平台上分发 Java 应用程序.它包含已编译的 Java 类文件 + 一些其他文件,如 MANIFEST.基本上它只是一个有一些限制的 ZIP 档案.

JAR (Java Archive)

JAR is a package file format designed for distribution of Java application on its platform. It contains compiled Java class files + some more files like MANIFEST. Basically it is just an ZIP archive with some restrictions.

DEX 是二进制文件格式,所以它被编译.我们可以说,.dex 文件适用于 DVM(Dalvik 虚拟机),类似于 JVM 的 .class 文件.

DEX is binary file format, so it is compiled. We could say, that .dex file is for DVM (Dalvik Virtual Machine) something like .class files for JVM.

DEX 文件格式实际上是由 Android SDK 中的 dex 编译器从 java CLASS 文件生成的.这个编译器把JVM字节码转成DVM字节码,把所有的class文件放到一个dex文件中.

DEX file format is really generated from java CLASS files by dex compiler from Android SDK. This compiler translates JVM bytecode to DVM bytecode and put all class files to one dex file.

APK 是专为在其平台上分发 Android 应用程序而设计的文件格式.它与 JAR 格式有一些相似之处.同样,它只是一个 ZIP 存档,但 APK 文件具有预定义的特定结构.例如,它必须始终包含名为 AndroidManifest.xml 的文件等等.这个包也以 dex 格式聚合编译的类.

APK is file format designed for distributing Android application on its platform. It has some similarities with JAR format. Again it is simply just a ZIP archive, but APK files have pre-defined specific structure. For example, it always must contains file named AndroidManifest.xml and many more. Also this package aggregates compiled classes in dex format.

AAR 是 Android 库项目的二进制分发版.它的结构与APK相似.

AAR is the binary distribution of an Android Library Project. It has similar structure as APK.

这篇关于Android中AAR、JAR、DEX、APK的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-23 05:33