简体   繁体   English

Android 2.3的Multidex(API 9)

[英]Multidex with Android 2.3 (API 9)

can anyone tell me if multi dex is supported in android 2.3? 谁有人能告诉我android 2.3中是否支持multi dex?

I've searched around but i can't find information for this. 我已经四处寻找,但我无法找到相关信息。 My project have the same configuration like this one: https://github.com/mustafa01ali/MultiDexTest 我的项目具有与此类似的配置: https//github.com/mustafa01ali/MultiDexTest

The project builds without problem, but the final apk can't be installed in devices with 2.3 or lower. 该项目构建没有问题,但最终的apk无法安装在2.3或更低的设备中。

On installation I get the error 在安装时我收到错误

Failure [INSTALL_FAILED_DEXOPT]

in Android Studio and this appears in logcat: 在Android Studio中,它出现在logcat中:

E/dalvikvm﹕ LinearAlloc exceeded capacity (5242880), last=1384
W/installd﹕ DexInv: --- END '/data/app/xxx.apk' --- status=0x000b, process failed
E/installd﹕ dexopt failed on '/data/dalvik-cache/data@app@xxx.apk@classes.dex' res = 11

You're hitting a different size limitation (LinearAlloc), which according to this bug is not solved by multi-dex: 你正在达到一个不同的大小限制(LinearAlloc),根据这个bug,multi-dex无法解决这个问题:

https://code.google.com/p/android/issues/detail?id=78035 https://code.google.com/p/android/issues/detail?id=78035

From comment #7 in that bug: 来自该bug的评论#7:

There is already an option in dx allowing to force generation of smaller dex files: --set-max-idx-number= Unfortunately changing the default is not a solution since the linearAlloc limit can be reached at very different levels depending on the classes hierarchy and other criteria. dx中已经有一个选项允许强制生成较小的dex文件: - set-max-idx-number =不幸的是,更改默认值不是解决方案,因为根据类层次结构,可以在非常不同的级别达到linearAlloc限制和其他标准。

In addition for most applications, moving to multidex will only help to workaround the linearalloc limit for the installation. 此外,对于大多数应用程序,迁移到multidex只会帮助解决安装的linearalloc限制。 But the application will still crash against the same limit at execution. 但是应用程序仍然会在执行时遇到相同的限制。 The only working use case where I know multidex can help with linearalloc is when the apk does not contains one application but distinct pieces running in separate process. 我知道multidex可以帮助linearalloc的唯一工作用例是当apk不包含一个应用程序但在不同的进程中运行不同的部分时。

It's not clear that there's anything you can do to work around this limit, at least in the long term; 目前尚不清楚你能做些什么来解决这个限制,至少从长远来看是这样; you may need to simplify your app. 您可能需要简化您的应用。 There's another StackOverflow question here with some information and some workarounds that may get you up and running, at least for a while: 这里有另一个StackOverflow问题,其中包含一些可能让您启动并运行的信息和一些解决方法,至少在一段时间内:

How to avoid LinearAlloc Exceeded Capacity error android 如何避免LinearAlloc Exceeded Capacity错误android

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM