运行包含大量代码的应用程序 [英] Running apps containing large amount of code

查看:204
本文介绍了运行包含大量代码的应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

似乎有些旧的Android操作系统(甚至是最新的)对每个应用可以容纳的代码量有限制。

It seems some old Android OSs (and maybe even the newest ones) have a limitation on the amount of code each app can hold.

如我所见,限制是在一个称为LinearAlloc的缓冲区上。

As I've found, the limitation is on a buffer called "LinearAlloc" .

在2.2或2.3之间,大约是5-8 MB,我认为其他人是16以上。

On 2.2 or 2.3 it's about 5-8 MB , and I think it's 16 or more on others.

如果您的代码太大(应用可以达到此状态),您将无法在旧设备上安装该应用程序,得到下一个错误(也报告了 这里 ) :

If you have a too large code (and apps can reach this state), you won't be able to install the app at all on older devices, getting the next error (also reported here) :

Installation error: INSTALL_FAILED_DEXOPT
Please check logcat output for more details.
Launch canceled!



我发现了



解决方案是尽可能地删除尽可能多的代码和库,但在一些巨大的项目上,这样的事情是很难做的。

What I've found

One solution is to just remove as much code and libraries as possible, but on some huge projects such a thing is very hard to do.

我发现下一个链接说关于Facebook如何解决这个问题,以某种方式增加限制:

I've found the next links talking about how Facebook solved this, by somehow increasing the limit:

  • http://www.slashgear.com/how-facebook-fixed-its-gingerbread-dalvik-problem-04272478/
  • http://arstechnica.com/business/2013/03/how-facebook-dug-deep-within-android-to-fix-its-mobile-app/
  • https://www.facebook.com/notes/facebook-engineering/under-the-hood-dalvik-patch-for-facebook-for-android/10151345597798920

此外,Google已经发布了如何通过动态加载代码来解决问题:

Also, Google has posted how to solve it by loading code dynamically :

http://android-developers.blogspot.co.il/2011/07/custom-class-loading-in-dalvik.html



< h2>问题

Facebook如何做?

The question

How did Facebook do it?

是否有可能以其他方式克服这个问题?

Is it possible to overcome this in other ways too?

有没有免费的图书馆增加/删除这个缓冲区的限制?

Is there any free library that increases/removes the limitation of this buffer?

有什么限制更新的Android版本,如果有什么?

What is the limitation on newer Android versions, if there is any?

其他巨大的应用程序(和游戏)如何处理这个问题?他们把代码放到C / C ++中吗?

How do other huge apps (and games) handle this issue? Do they put their code into C/C++?

将加载dex文件动态解决这个问题吗?

Would loading the dex files dynamically solve this?

推荐答案

限制是方法引用的总数:

The limit is the total number of method references:

  • https://code.google.com/p/android/issues/detail?id=7147#c6
  • https://code.google.com/p/android/issues/detail?id=20814#c6

A FB / Google文章中描述的无法执行的多重dex方法之间的中间位置是使用ProGuard等工具来删除对Java级别的未使用代码的引用。请参阅:

A middle ground between doing nothing and the multi-dex approach described in the FB/Google articles is to use a tool like ProGuard to remove references to unused code at the Java level. See:

  • http://proguard.sourceforge.net/
  • http://developer.android.com/tools/help/proguard.html

这篇关于运行包含大量代码的应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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