Android的MultiDex - 对内部工作问题 [英] Android MultiDex - Questions on Inner Workings

查看:161
本文介绍了Android的MultiDex - 对内部工作问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近发现从Android的新MultiDex功能与具有超过65,000个应用程序引用工作。请参阅: https://developer.android.com/tool​​s/building/multidex.html

I recently discovered the new MultiDex functionality from Android for working with apps having more than 65,000 references. See: https://developer.android.com/tools/building/multidex.html

有人可以帮助我了解以下问题:

Can someone help me understand the following questions:

1)如何在摇篮打造插件确定将在主DEX文件(classes.dex)与二级DEX文件是什么?根据商务部有是在初级DEX需要某些东西,但它并没有给出任何例子。规定,所有活动将在主DEX文件?

1) How does the Gradle build plugin determine what to put in the primary dex file (classes.dex) vs the secondary dex files? Based on the doc there are certain things required to be in primary dex but it doesn't give any examples. Are all activities required to be in the primary dex file?

引用的文字:

有关于需要什么样的班复杂的需求   执行中的Dalvik运行在主DEX文件。而Android   构建工具的更新处理Android的要求,但它是   可能其他包括图书馆有更多的相关性   要求包括使用内省或Java的调用   方法从本地code。一些库可能无法使用   直到multidex构建工具的更新,让您指定   类必须包括在主DEX文件

There are complex requirements regarding what classes are needed in the primary dex file when executing in the Dalvik runtime. The Android build tooling updates handle the Android requirements, but it is possible that other included libraries have additional dependency requirements including the use of introspection or invocation of Java methods from native code. Some libraries may not be able to be used until the multidex build tools are updated to allow you to specify classes that must be included in the primary dex file.

2)如果只为Android API级别21(安卓L)及以上的建筑物,有不同的行为在摇篮生成插件。它说,它的速度要快得多,因为它构建应用程序(包括相关性)作为单独的DEX文件中的每个模块。这就是通常所说的pre-德兴。在Android的一个模块的定义是什么?难道这就是Java库,Android的图书​​馆,和Android应用模块这里所说的: HTTP ://developer.android.com/sdk/installing/studio-build.html#projectModules ?进行远程或本地二进制依赖(例如:罐)?算作独立的模块,从而得到放入不同的DEX文件或他们得到包含在模块依赖​​于它们

2) When building only for Android API Level 21 (Android L) and above, there is different behavior in the Gradle Build Plugin. It says it is much faster because it "Builds each module of the application (including dependencies) as separate dex files. This is commonly referred to as pre-dexing." What is the definition of a module in Android? Is this the Java Library, Android Library, and Android application modules mentioned here: http://developer.android.com/sdk/installing/studio-build.html#projectModules? Do Remote or Local Binary Dependencies (ex:Jars) count as separate modules and thus get put into a different dex file or do they get included in the module depending on them?

推荐答案

1)的摇篮插件在内部使用Proguard的在中间体/多DEX创建两个jar文件建立文件夹。一会是主要的DEX,其余的将为s $ P $垫出了地塞米松2,3等。

1) The gradle plugin internally uses Proguard to create two jar files in the intermediates/multi-dex build folder. One will be the primary dex, the rest will be spread out over dex 2, 3 etc.

收集{变量} MultiDexComponents 任务是负责创造ProGuard的该保留的文件,你可以看到这个文件,并在该变体的具体子目录中使用的其他ProGuard的参数文件夹我上面提到的。希望这将是定制的,从长远来看。

The collect{variant}MultiDexComponents task is responsible for creating the keep file for proguard, you can see this file and other proguard parameters used in the variant specific subdirectory of the folder I mentioned above. Hopefully this will be customisable in the long run.

还有一个目前有关试验项目1.0.0-RC1的摇篮插件(的 HTTPS://$c$c.google.com/p/android/issues/detail ID = 80741 )。随着一些小的变化,我的解决方法有贴也可以用你自己的条目添加到列表保持(从而保证你的类最终在主DEX)现在。

There is also currently a bug relating to test projects in 1.0.0-rc1 of the gradle plugin (https://code.google.com/p/android/issues/detail?id=80741). With some small changes the workaround I posted there can also be used to add your own entries to the keep list (thus ensuring your classes end up in the primary dex) right now.

2)的模块指的模块从摇篮的角度来看,但这些确实可以在你链接到列表中提到的不同项目。如果你做了pre-棒棒糖摇篮从命令行建立与 - 信息作为一个标志,你可以看到所有的DEX文件传递给 DX 。 (请注意,这应该不是一个multidex启用编译或具有 preDexLibraries = FALSE )。

2) Modules refer to modules from a Gradle perspective, but these can indeed be the different items mentioned in the list you linked to. If you do a pre-lollipop gradle build from the commandline with --info as a flag you can see all the dex files being passed to dx. (Note that this should not a multidex enabled build or one with preDexLibraries = false).

这篇关于Android的MultiDex - 对内部工作问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆