Multidexing android应用程序的缺点 [英] Disadvantages in Multidexing the android application

查看:90
本文介绍了Multidexing android应用程序的缺点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

最近,我已阅读有关Dalvik 65K方法限制的信息。我知道方法调用列表只能调用第一个65536个方法引用。
为了解决这个问题,我们有许多解决方案。其中一种是多义处理,我们使用android的支持库将.dex文件拆分为类数[classes.dex,classes1.dex ...]。



什么我无法理解的是,由于这种多义性,android应用程序会遭受什么弊端,为什么我们要花很多精力来尽量减少引用方法的数量。



基本上,为了减少方法数量,我必须减少模块化,这使我的代码可读性降低,从而减少了精简代码所花费的时间第三方库。正在减少方法数量值得吗?

解决方案

您对multidex的想法过高,相反,您应该通过对应用程序进行性能分析来观察并确定您的应用程序是否存在性能问题。



多义处理几乎不会增加任何代码大小,主要大小和性能问题是动画/图像/音频/视频资源,它们是增加大小和降低性能的问题。



包括许多第三方库最终将超过64k限制,如今几乎所有应用程序都是多义的,用户今天需要多功能的应用程序,这需要与许多第三方库集成。



仅当您在进行动画/游戏编程时,速度才是最重要的,更多的方法调用可能是有害的,但这与多义处理无关,甚至写得不好小型非multidexing应用程序在任何设备上的性能都将不佳。


正在减少方法计数值得




理想情况下,您应该使用更多方法并对代码进行模块化,因为发布后,测试和更改移动应用程序是巨大的挑战。调试和消除错误的成本要比多倍体大小及其对性能的影响高。由于屏幕很小,品牌不同,用户界面不同,因此与计算机相比,用户对手机上的应用程序更加恼火。如果将代码分为多个单独的经过测试的库,则满足用户需求将变得更加容易。


Recently I have read about the Dalvik 65K method limit. I have understood that the method invocation list can only invoke first 65536 method references. To tackle this we have number of solutions. One of which being multidexing where we split the .dex files to number of classes [classes.dex, classes1.dex ...] by using android's support library.

What I have failed to understand is, what drawback does an android application suffer due to this multidexing and why should we put lots of effort in minimising the number of referenced methods.

Basically in my understanding, to reduce the method count I have to reduce modularisation, which makes my code bit less readable leaving apart the number of hours burned in striping down the codes of Third-party libraries. Is reducing the method count worth it??

解决方案

You are overthinking about multidex, instead you should observe and identify if there is any performance issue with your app by profiling your application.

Multidexing hardly increases any size of code, major size and performance issues are with animation/image/audio/video resources, they are the ones who increase size and reduce performance.

Including many third party libraries will eventually pass 64k limit and almost all applications today are multidexed, Users demand multifeatured apps today, that requires integration with many third party libraries.

Only when you are doing animation/game programming, where speed matters the most, more method calls might be harmful, but this has nothing to do with multidexing, even poorly written small non multidexing app will perform bad on any device.

Startup time will affect with multidexing, but it can certainly be improved by changing your app logic to delay loading of other costly library and resources.

Is reducing the method count worth it??

NO

Ideally you should use more methods and modularize your code, because testing and changing mobile apps is huge challenge after it is published. Debugging and removing bugs are more costly then multidex size and its impact on performance. Due to tiny screens, different brands, different UI, users get more angry on apps on phone compared to computers. Keeping up to users demand will become easier if code is divided into multiple individual tested libraries.

这篇关于Multidexing android应用程序的缺点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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