使用本机库发送Android Codename One Build我得到了DexIndexOverflowException

时间:2015-11-24 14:57:55

标签: android codenameone

我正在将原生的第三方库集成到Codename One中,并且在构建日志底部的构建过程中出现以下错误:

       [dx] Merged dex A (1099 defs/2414.7KiB) with dex B (1 defs/0.4KiB). Result is 1100 defs/3068.7KiB. Took 0.9s
       [dx] Result compacted from 4131.2KiB to 2416.3KiB to save 1714.8KiB
       [dx] Merged dex A (1100 defs/3068.7KiB) with dex B (4 defs/3.5KiB). Result is 1104 defs/2416.3KiB. Took 0.8s
       [dx] Result compacted from 7298.5KiB to 5991.1KiB to save 1307.4KiB
       [dx] Merged dex A (1104 defs/2416.3KiB) with dex B (4118 defs/3577.8KiB). Result is 5222 defs/5991.1KiB. Took 0.9s
       [dx] 
       [dx] UNEXPECTED TOP-LEVEL EXCEPTION:
       [dx] com.android.dex.DexIndexOverflowException: method ID not in [0, 0xffff]: 65536
       [dx]     at com.android.dx.merge.DexMerger$6.updateIndex(DexMerger.java:502)
       [dx]     at com.android.dx.merge.DexMerger$IdMerger.mergeSorted(DexMerger.java:283)
       [dx]     at com.android.dx.merge.DexMerger.mergeMethodIds(DexMerger.java:491)
       [dx]     at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:168)
       [dx]     at com.android.dx.merge.DexMerger.merge(DexMerger.java:189)
       [dx]     at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:502)
       [dx]     at com.android.dx.command.dexer.Main.runMonoDex(Main.java:334)
       [dx]     at com.android.dx.command.dexer.Main.run(Main.java:277)
       [dx]     at com.android.dx.command.dexer.Main.main(Main.java:245)
       [dx]     at com.android.dx.command.Main.main(Main.java:106)
       [dx] 

BUILD FAILED
/home/ec2-user/android-sdk/tools/ant/build.xml:888: The following error occurred while executing this line:
/home/ec2-user/android-sdk/tools/ant/build.xml:890: The following error occurred while executing this line:
/home/ec2-user/android-sdk/tools/ant/build.xml:902: The following error occurred while executing this line:
/home/ec2-user/android-sdk/tools/ant/build.xml:283: null returned: 2

1 个答案:

答案 0 :(得分:2)

Androids DEX APK格式有一个64k的方法计数限制,一旦你开始使用多个大型库,就很容易超过。不幸的是,使用Ant来解决它是不可能的,所以你需要切换到新的Gradle based build system(这将是目前定于2016年1月的Codename One 3.3的默认值)。

在3.3之前,您可以定义构建提示android.gradle=true

然后,您需要定义构建提示android.multidex=true以解决该特定错误。