Android的档案库(AAR)比标准瓶 [英] Android Archive Library (aar) vs standard jar
问题描述
我一直在阅读有关的新的应用摇篮为标准构建系统为Android应用程序的一些文章。那么,从标准的Java开发未来我通常依靠的罐的文件,以建立我的项目。然而似乎Android有也 AAR 的包,这是相当于在Windows操作系统中的的dll 的文件,如上述<一个href="http://blog.glassdiary.com/post/67134169807/how-to-share-android-archive-library-aar-across">here:
I've been reading some articles about the new adoption of Gradle as the standard build system for Android apps. Well, coming from standard Java development I usually depend on jar files in order to build my project. However it seems that Android has also aar packages, which are the equivalent to the dll files in a Windows OS, as mentioned here:
首先,你必须认识到,在Android平台上不允许应用程序级的共享库。在传统的编程语言平台,C,C ++,Java的,你的名字,我们有共享的运行时库这一机制。 (例如,DLL在Windows上,DSO在Unix上,瓶子在JVM等)。在Android上,但是,你不能这样做,除非你是谷歌还是手机制造商(见下文脚注1)。作为应用程序开发,这可以是一个基本的限制。 共享或再利用codeS,无论是在编译时和运行时,是软件工程实践中非常重要的一部分。这是相当困难(并非不可能,只是硬)的Android上,因为前面提到的限制。
First, you have to realize that the Android platform does not allow application-level "shared libraries". In the "traditional" programming language platforms, C, C++, Java, you name it, we have this mechanism of sharing runtime libraries. (E.g., DLL on Windows, DSO on Unix, Jar on JVM, etc.). On Android, however, you cannot do that, unless you are Google or a handset manufacturer (See Footnote 1 below). As an application developer, this can be a fundamental limitation. "Sharing" or "reusing" codes, both at build time and run time, is a very important part of software engineering practice. This is rather hard (not impossible, just harder) on Android because of the aforementioned limitation.
不过,我身边这个概念有些疑惑。我的意思是,如果要开发有兴趣,包括的 AAR 的相关性在其应用程序?此依赖关系拧紧到一个SDK最低版本?
However, I have some doubts around this concept. I mean, when should a developer be interested including aar dependencies in its application? Are this dependencies tightened to a SDK minimum version?
例如,在一个项目中,我获得一个COM口,我用 NDK precompiled 的的.so 的图书馆。我一定要创建一个AAR,如果我想分享这个工具?
For example, in one project I access a COM port, which I use NDK precompiled .so libraries for. Do I have to create an aar if I want to share this utility?
推荐答案
AAR
文件更类似于罐
总比到 DLL
S为以下原因:
AAR
files are more similar to Jar
s than to Dll
s for the following reason:
DLL
S能跨应用程序,其中的 AAR
和罐子共享
打包在你的应用程序。
Dll
s can be shared across applications where asAAR
s and jars are packaged in with your app.
AAR
s和罐
S:
在罐
和 AAR
之间的主要区别是, AAR $ C $ç>取值包括:
如
布局,可绘制
等,这使得它容易得多的资源
创建自包含的可视化组件。例如,如果你有
使用同一个登录界面多个应用程序,用罐
是你可以
股份类别,但没有布局,样式等,你还是得
复制它们。随着 AAR
一切都好捆绑在一个整洁的包。
The main difference between a
Jar
and aAAR
is thatAAR
s include resources such aslayouts, drawables
etc. This makes it a lot easier to create self-contained visual components. For example if you have multiple apps that use the same login screen, withJar
s you could share classes but not the layout, styles, etc., you still had to duplicate them. WithAAR
s everything is bundled in one neat package.
在最后, AAR
是在正确的方向迈出了一大步。
In conclusion, AAR
s are a big step in the right direction.
注意:
类似的企图被用 APK-LIB
赚了,但他们现在已经过时,因为 AAR
是好多了。
Note:
Similar attempts were made with apk-lib
s but they are now obsolete as AAR
s are much better.
这篇关于Android的档案库(AAR)比标准瓶的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!