更新到Android Studio 1.4和最新SDK后,构建失败

时间:2015-10-07 09:07:09

标签: android android-studio sdk

更新到Android Studio 1.4后,IDE要求更新到最新的插件和sdk,下载大约1.2 Gb,所以我更新了,当我构建项目时,我收到此错误:

Information:Gradle tasks [:app:generateDebugSources, :app:generateDebugAndroidTestSources, :app:assembleDebug]
    :app:preBuild UP-TO-DATE
    :app:preDebugBuild UP-TO-DATE
    :app:checkDebugManifest
    :app:preReleaseBuild UP-TO-DATE
    :app:prepareComAndroidSupportAppcompatV72221Library UP-TO-DATE
    :app:prepareComAndroidSupportCardviewV72103Library UP-TO-DATE
    :app:prepareComAndroidSupportDesign2221Library UP-TO-DATE
    :app:prepareComAndroidSupportMediarouterV72220Library UP-TO-DATE
    :app:prepareComAndroidSupportPaletteV72103Library UP-TO-DATE
    :app:prepareComAndroidSupportRecyclerviewV72103Library UP-TO-DATE
    :app:prepareComAndroidSupportSupportV42221Library UP-TO-DATE
    :app:prepareComBalysvMaterialRipple102Library UP-TO-DATE
    :app:prepareComBalysvMaterialmenuMaterialMenu154Library UP-TO-DATE
    :app:prepareComBalysvMaterialmenuMaterialMenuToolbar154Library UP-TO-DATE
    :app:prepareComDaimajiaAndroidanimationsLibrary113Library UP-TO-DATE
    :app:prepareComDaimajiaEasingLibrary101Library UP-TO-DATE
    :app:prepareComDaimajiaSliderLibrary115Library UP-TO-DATE
    :app:prepareComEtsyAndroidGridLibrary105Library UP-TO-DATE
    :app:prepareComGithubAmlcurranShowcaseviewLibrary500Library UP-TO-DATE
    :app:prepareComGithubAsylAnimationArcanimator100Library UP-TO-DATE
    :app:prepareComGithubCastorflexSmoothprogressbarLibrary110Library UP-TO-DATE
    :app:prepareComGithubCastorflexSmoothprogressbarLibraryCircular110Library UP-TO-DATE
    :app:prepareComGithubPwittchenPrefser105Library UP-TO-DATE
    :app:prepareComGoogleAndroidGmsPlayServices810Library UP-TO-DATE
    :app:prepareComGoogleAndroidGmsPlayServicesAds810Library UP-TO-DATE
    :app:prepareComGoogleAndroidGmsPlayServicesAnalytics810Library UP-TO-DATE
    :app:prepareComGoogleAndroidGmsPlayServicesAppindexing810Library UP-TO-DATE
    :app:prepareComGoogleAndroidGmsPlayServicesAppinvite810Library UP-TO-DATE
    :app:prepareComGoogleAndroidGmsPlayServicesAppstate810Library UP-TO-DATE
    :app:prepareComGoogleAndroidGmsPlayServicesBase810Library UP-TO-DATE
    :app:prepareComGoogleAndroidGmsPlayServicesBasement810Library UP-TO-DATE
    :app:prepareComGoogleAndroidGmsPlayServicesCast810Library UP-TO-DATE
    :app:prepareComGoogleAndroidGmsPlayServicesDrive810Library UP-TO-DATE
    :app:prepareComGoogleAndroidGmsPlayServicesFitness810Library UP-TO-DATE
    :app:prepareComGoogleAndroidGmsPlayServicesGames810Library UP-TO-DATE
    :app:prepareComGoogleAndroidGmsPlayServicesGcm810Library UP-TO-DATE
    :app:prepareComGoogleAndroidGmsPlayServicesIdentity810Library UP-TO-DATE
    :app:prepareComGoogleAndroidGmsPlayServicesLocation810Library UP-TO-DATE
    :app:prepareComGoogleAndroidGmsPlayServicesMaps810Library UP-TO-DATE
    :app:prepareComGoogleAndroidGmsPlayServicesMeasurement810Library UP-TO-DATE
    :app:prepareComGoogleAndroidGmsPlayServicesNearby810Library UP-TO-DATE
    :app:prepareComGoogleAndroidGmsPlayServicesPanorama810Library UP-TO-DATE
    :app:prepareComGoogleAndroidGmsPlayServicesPlus810Library UP-TO-DATE
    :app:prepareComGoogleAndroidGmsPlayServicesSafetynet810Library UP-TO-DATE
    :app:prepareComGoogleAndroidGmsPlayServicesVision810Library UP-TO-DATE
    :app:prepareComGoogleAndroidGmsPlayServicesWallet810Library UP-TO-DATE
    :app:prepareComGoogleAndroidGmsPlayServicesWearable810Library UP-TO-DATE
    :app:prepareComGordonwongMaterialSheetFab103Library UP-TO-DATE
    :app:prepareJpWasabeefRecyclerviewAnimators122Library UP-TO-DATE
    :app:prepareNetSimonvtMenudrawerMenudrawer306Library UP-TO-DATE
    :app:prepareOrgSufficientlysecureHtmlTextview12Library UP-TO-DATE
    :app:prepareDebugDependencies
    :app:compileDebugAidl UP-TO-DATE
    :app:compileDebugRenderscript UP-TO-DATE
    :app:generateDebugBuildConfig UP-TO-DATE
    :app:generateDebugAssets UP-TO-DATE
    :app:mergeDebugAssets UP-TO-DATE
    :app:generateDebugResValues UP-TO-DATE
    :app:generateDebugResources UP-TO-DATE
    :app:mergeDebugResources UP-TO-DATE
    :app:processDebugManifest UP-TO-DATE
    :app:processDebugResources UP-TO-DATE
    :app:generateDebugSources UP-TO-DATE
    :app:preDebugAndroidTestBuild UP-TO-DATE
    :app:prepareDebugAndroidTestDependencies
    :app:compileDebugAndroidTestAidl UP-TO-DATE
    :app:processDebugAndroidTestManifest UP-TO-DATE
    :app:compileDebugAndroidTestRenderscript UP-TO-DATE
    :app:generateDebugAndroidTestBuildConfig UP-TO-DATE
    :app:generateDebugAndroidTestAssets UP-TO-DATE
    :app:mergeDebugAndroidTestAssets UP-TO-DATE
    :app:generateDebugAndroidTestResValues UP-TO-DATE
    :app:generateDebugAndroidTestResources UP-TO-DATE
    :app:mergeDebugAndroidTestResources UP-TO-DATE
    :app:processDebugAndroidTestResources UP-TO-DATE
    :app:generateDebugAndroidTestSources UP-TO-DATE
    :app:compileDebugNdk UP-TO-DATE
    :app:compileDebugJava UP-TO-DATE
    :app:preDexDebug UP-TO-DATE
    :app:dexDebug
    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:303)
        at com.android.dx.command.dexer.Main.run(Main.java:246)
        at com.android.dx.command.dexer.Main.main(Main.java:215)
        at com.android.dx.command.Main.main(Main.java:106)
    Error:Execution failed for task ':app:dexDebug'.
    > com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '/Library/Java/JavaVirtualMachines/jdk1.7.0_75.jdk/Contents/Home/bin/java'' finished with non-zero exit value 2

我认为它必须是与库版本相关的东西,可能是因为它们不是最新版本。有关如何处理此错误的任何线索?

1 个答案:

答案 0 :(得分:2)

您收到此错误是因为您已超出65k方法限制:

  

Android应用程序(APK)文件包含可执行的字节码文件   Dalvik可执行文件(DEX)文件的形式,包含已编译的文件   用于运行您的应用的代码。 Dalvik可执行规范限制   单个DEX中可引用的方法总数   文件到65,536,包括Android框架方法,库方法,   和你自己的代码中的方法。超过此限制需要这样做   您配置应用程序构建过程以生成多个DEX   文件,称为multidex配置。

您可以在此处找到有关65K方法的更多信息以及避免此问题的方法: https://developer.android.com/tools/building/multidex.html