更新后,我在Android Studio中遇到问题

时间:2015-09-15 07:46:37

标签: android android-studio

我将Android Studio更新到版本1.4 beta 3,更新后它在SDK上给我一个错误。

我实际上并不知道它是什么,但我试图更改SDK,但似乎没有任何改变。

这是消息标签中的错误:

    Error:Execution failed for task ':app:dexDebug'.
> com.android.ide.common.internal.LoggedErrorException: Failed to run command:
    E:\Android-DEV\adt-bundle-windows-x86_64-20140321\adt-bundle-windows-x86_64-20140321\sdk\build-tools\build-tools-21.1.1\dx.bat --dex --no-optimize --output E:\AndroidStudioWorkspace\NumbersFinder\app\build\intermediates\dex\debug --input-list=E:\AndroidStudioWorkspace\NumbersFinder\app\build\intermediates\tmp\dex\debug\inputList.txt
Error Code:
    2
Output:
    UNEXPECTED TOP-LEVEL EXCEPTION:
    com.android.dex.DexIndexOverflowException: method ID not in [0, 0xffff]: 65536
        at com.android.dx.merge.DexMerger$6.updateIndex(DexMerger.java:502)
        at com.android.dx.merge.DexMerger$IdMerger.mergeSorted(DexMerger.java:277)
        at com.android.dx.merge.DexMerger.mergeMethodIds(DexMerger.java:491)
        at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:168)
        at com.android.dx.merge.DexMerger.merge(DexMerger.java:189)
        at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:454)
        at com.android.dx.command.dexer.Main.runMonoDex(Main.java:302)
        at com.android.dx.command.dexer.Main.run(Main.java:245)
        at com.android.dx.command.dexer.Main.main(Main.java:214)
        at com.android.dx.command.Main.main(Main.java:106)

1 个答案:

答案 0 :(得分:0)

达到默认的 64K 方法限制后,可能会出现此错误。

请参见此处https://developer.android.com/tools/building/multidex.html

一个简单的解决方案是从gradle添加 multiDexEnabled

尝试从 build.gradle 启用 multidex

    android {
       defaultConfig {
          ...
          multiDexEnabled = true
       }
}