Filip Luchianenco
Filip Luchianenco

Reputation: 7012

Build Failed after updating to Android Studio 1.4 and latest SDK

After updating to Android Studio 1.4, the IDE asked to update to latest plugins and sdk, it was about 1.2 Gb to download, so I updated and when I build the project I get this error:

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

I suppose it has to be something related to libraries versions, maybe because they are not the latest version. Any clue on how to deal with this error?

Upvotes: 0

Views: 228

Answers (1)

Mattia Maestrini
Mattia Maestrini

Reputation: 32780

You receive this error because you have exceeded the 65k methods limit:

Android application (APK) files contain executable bytecode files in the form of Dalvik Executable (DEX) files, which contain the compiled code used to run your app. The Dalvik Executable specification limits the total number of methods that can be referenced within a single DEX file to 65,536, including Android framework methods, library methods, and methods in your own code. Getting past this limit requires that you configure your app build process to generate more than one DEX file, known as a multidex configuration.

You can find more information about 65K Methods and the methods to avoid the issue here: https://developer.android.com/tools/building/multidex.html

Upvotes: 2

Related Questions