Android的工作室只! DexException:不能合并新的索引65536到非巨型指令指令、索引、工作室、Android

2023-09-04 08:23:09 作者:休書づ絕愛

对于一些未知的原因,我的应用程序突然无法从Android的工作室打造。

For some unknown reason my app suddenly won't build from Android Studio.

我不断收到

> com.android.ide.common.internal.LoggedErrorException: Failed to run command:
    /home/martynas/android-sdk/build-tools/19.1.0/dx --dex --num-threads=4 --output
...
...
...
Error Code:
2
Output:
UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dex.DexException: Cannot merge new index 65536 into a non-jumbo instruction!

当相同的应用被成功地从命令行建造。 我检查方法引用计数和它下面的可怕的64K方式。

While the same application is built successfully from command line. I've checked method references count and it's way below the dreaded 64k.

我使用的AS 0.8.11了。

I'm using AS 0.8.11 now.

推荐答案

尝试添加该行会在project.properties

dex.force.jumbo = TRUE

dex.force.jumbo=true

这增加了限制在DEX文件中的字符串。和你的项目可能会进行编译。

Which increment the limit for strings in a dex files. And your project will probably compile.

注意:同时与巨型集,是64K的仅适用于一个单一的DEX方法的另一个限制。如果你在未来得到这个限度,你将需要删除一些依赖。

Note : Also with jumbo set, the is another limit of 64K only for methods in an single dex. If you get this limit in the future , you will need to remove some dependencies.

更新 - 谷歌播放服务6.5(14年12月8日)

使用6.5版本的谷歌终于拆零的谷歌播放服务。所以,从现在开始,这将是可能的选择编译的API到你的可执行文件。

With version 6.5 Google finally unbundled the Google Play Services. So from now on it'll be possible to selectively compile the APIs into your executable.

示例:

编译com.google.android.gms:玩-服务-图:6.5 +。 编译com.google.android.gms:播放服务,广告:6.5 +

compile 'com.google.android.gms:play-services-maps:6.5.+' compile 'com.google.android.gms:play-services-ads:6.5.+'

对于所有其他个体谷歌播放服务API检查d.android.com此页面。

For all the other individual Google Play Services APIs check this page on d.android.com.

更新(21-04-2015): https://developer.android.com/tools/building/multidex.html

Update (21-04-2015) : https://developer.android.com/tools/building/multidex.html