【问题标题】:Weird : UNEXPECTED TOP-LEVEL EXCEPTION: Execution failed for task app:dexDebug奇怪:意外的顶级异常:任务应用程序执行失败:dexDebug
【发布时间】:2015-04-01 21:30:03
【问题描述】:

我没有实现新的库,但是在编码时出现了这个问题:

错误:任务 ':app:dexDebug' 执行失败。

com.android.ide.common.internal.LoggedErrorException:无法运行命令: C:\android-sdk\build-tools\21.1.1\dx.bat --dex --no-optimize --output F:\Android_Donbas\ReDonbasIDEANew\app\build\intermediates\dex\debug --input-list =F:\Android_Donbas\ReDonbasIDEANew\app\build\intermediates\tmp\dex\debug\inputList.txt 错误代码: 2 输出: 意外的顶级异常: com.android.dex.DexIndexOverflowException:方法 ID 不在 [0, 0xffff] 中:65536 在 com.android.dx.merge.DexMerger$6.updateIndex(DexMerger.java:502) 在 com.android.dx.merge.DexMerger$IdMerger.mergeSorted(DexMerger.java:277) 在 com.android.dx.merge.DexMerger.mergeMethodIds(DexMerger.java:491) 在 com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:168) 在 com.android.dx.merge.DexMerger.merge(DexMerger.java:189) 在 com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:454) 在 com.android.dx.command.dexer.Main.runMonoDex(Main.java:302) 在 com.android.dx.command.dexer.Main.run(Main.java:245) 在 com.android.dx.command.dexer.Main.main(Main.java:214) 在 com.android.dx.command.Main.main(Main.java:106)

我的 build.gradle:

 dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:support-v4:21.0.3'
    compile 'com.google.android.gms:play-services:6.5.87'
    compile 'com.google.code.gson:gson:2.3'
    compile 'com.google.code.gson:gson:2.3'
    compile 'com.google.code.gson:gson:2.2.2'
    compile 'com.google.guava:guava:18.0'
    compile 'com.android.support:appcompat-v7:20.0.0'
    compile files('libs/android-async-http-1.4.6.jar')
    compile files('libs/AndroidSwipeLayout-v1.1.6.jar')
    compile files('libs/apache-mime4j-0.5.jar')
    compile files('libs/crashlytics.jar')
    compile files('libs/httpclient-4.2.1.jar')
    compile files('libs/httpcore-4.2.1.jar')
    compile files('libs/httpmime-4.2.1.jar')
    compile files('libs/nineoldandroids-2.4.0.jar')
    compile files('libs/ormlite-android-4.48.jar')
    compile files('libs/ormlite-core-4.48.jar')
    compile files('libs/ormlite-jdbc-4.48.jar')
    compile files('libs/osmdroid-android-4.2.jar')
    compile files('libs/slf4j-android-1.6.1-RC1.jar')
    compile files('libs/universal-image-loader-1.9.3.jar')
}



packagingOptions {
        exclude 'META-INF/NOTICE.txt'
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/DEPENDENCIES'
        exclude 'META-INF/NOTICE'
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/NOTICE.t'
    }

【问题讨论】:

    标签: android


    【解决方案1】:

    您可能已达到 65k 方法的限制。要使用更精细的 Google Play 服务,请关注this guide,您可以只使用您想要的部分。这可能会解决您的问题。

    【讨论】:

    【解决方案2】:

    您可以通过在 build.gradle 中添加“multiDexEnabled true”来启用 multdex 来解决限制问题。欲了解更多信息,请参阅http://android-developers.blogspot.com.es/2014/12/google-play-services-and-dex-method.html

    来自Why did this happen? How do i fix this? Android: UNEXPECTED TOP-LEVEL EXCEPTION:

    【讨论】:

      【解决方案3】:

      在 build.gradle 的 defaultConfig 中添加 multiDexEnabled true 解决了我的问题

      defaultConfig {
              applicationId "com.example.project"
              minSdkVersion 15
              targetSdkVersion 21
              versionCode 1
              versionName "1.0.0"
              multiDexEnabled true
          }
      

      【讨论】:

        【解决方案4】:

        我通过在 build gradle 中添加这些解决了我的问题:

            defaultConfig {
              multiDexEnabled true
        
        
            dependencies {
              compile 'com.android.support:multidex:1.0.0'
        

        另一种解决方案是删除不必要的库

        【讨论】:

          猜你喜欢
          • 2014-09-25
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2021-11-28
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多