含有大量的code运行的应用程序应用程序、code

2023-09-05 07:54:47 作者:超越经典

这似乎一些老的Andr​​oid操作系统(甚至最新的)对的code每个应用程序可以容纳量的限制。

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.

如果您有太大code(和应用程序可以达到这个境界),您将无法在旧的设备上安装应用程序可言,得到下一个错误(也报道here)

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!

我发现什么

一个解决办法是只删除尽可能多的code和库成为可能,但在一些大型项目这样的事情是非常困难的事情。

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 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

此外,谷歌已经发布了如何通过加载code动态地解决这个问题:

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

问题

的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?

什么是新的Andr​​oid版本的限制,如果有任何?

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

如何做其他巨大的应用程序(和游戏)处理这个问题?难道他们把自己的code到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 https://code.google.com/p/android/issues/detail?id=7147#c6 https://code.google.com/p/android/issues/detail?id=20814#c6

无所事事,并在FB /谷歌文章中描述的多DEX方法之间的中间地带是使用诸如ProGuard的工具来删除在Java级别引用未使用code。参见:

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/tool​​s/help/proguard.html http://proguard.sourceforge.net/ http://developer.android.com/tools/help/proguard.html