3

I cannot get my program to run due to a problem inside my gradle. I recently added the dependency:

compile 'com.google.android.gms:play-services:7.3.0'

to my project. I am using it for maps in my project. But when I run the project, I get this error:

Information:Gradle tasks [:app:assembleDebug]
:app:preBuild UP-TO-DATE
:app:preDebugBuild UP-TO-DATE
:app:compileDebugNdk UP-TO-DATE
:app:checkDebugManifest
:app:preReleaseBuild UP-TO-DATE
:app:prepareComAndroidSupportAppcompatV72211Library UP-TO-DATE
:app:prepareComAndroidSupportSupportV42211Library UP-TO-DATE
:app:prepareComGithubShellSoftwareFab105Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServices730Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesAds730Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesAnalytics730Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesAppindexing730Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesAppinvite730Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesAppstate730Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesBase730Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesCast730Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesDrive730Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesFitness730Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesGames730Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesGcm730Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesIdentity730Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesLocation730Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesMaps730Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesNearby730Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesPanorama730Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesPlus730Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesSafetynet730Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesWallet730Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesWearable730Library 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: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.8.0_25.jdk/Contents/Home/bin/java'' finished with non-zero exit value 2
Information:BUILD FAILED
Information:Total time: 48.802 secs
Information:1 error
Information:0 warnings
Information:See complete output in console

I believe it's due to the compile line above, but I need it for part of my project. I'm not entirely sure what to do here.

EDIT: Here's my entire build.gradle:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 21
    buildToolsVersion "21.1.2"

    defaultConfig {
        applicationId "com.aszend.android"
        minSdkVersion 14
        targetSdkVersion 21
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:support-v4:22.1.1'
    compile 'com.android.support:appcompat-v7:22.1.1'
    compile files('libs/aws-android-sdk-autoscaling-2.2.1.jar')
    compile files('libs/aws-android-sdk-cloudwatch-2.2.1.jar')
    compile files('libs/aws-android-sdk-cognito-2.2.1.jar')
    compile files('libs/aws-android-sdk-core-2.2.1.jar')
    compile files('libs/aws-android-sdk-ddb-2.2.1.jar')
    compile files('libs/aws-android-sdk-ddb-mapper-2.2.1.jar')
    compile files('libs/aws-android-sdk-ec2-2.2.1.jar')
    compile files('libs/aws-android-sdk-elb-2.2.1.jar')
    compile files('libs/aws-android-sdk-kinesis-2.2.1.jar')
    compile files('libs/aws-android-sdk-lambda-2.2.1.jar')
    compile files('libs/aws-android-sdk-machinelearning-2.2.1.jar')
    compile files('libs/aws-android-sdk-mobilenalytics-2.2.1.jar')
    compile files('libs/aws-android-sdk-s3-2.2.1.jar')
    compile files('libs/aws-android-sdk-sdb-2.2.1.jar')
    compile files('libs/aws-android-sdk-ses-2.2.1.jar')
    compile files('libs/aws-android-sdk-sns-2.2.1.jar')
    compile files('libs/aws-android-sdk-sqs-2.2.1.jar')
    compile files('libs/Parse-1.9.1.jar')
    compile 'com.github.shell-software:fab:1.0.5'
    compile 'com.parse.bolts:bolts-android:1.2.0'
    compile 'com.google.android.gms:play-services:7.3.0'
}

All Help Is Appreciated

HTG
  • 584
  • 1
  • 8
  • 28

1 Answers1

10

It looks like your project has exceeded 65536 methods, from this line in the error:

com.android.dex.DexIndexOverflowException: method ID not in [0, 0xffff]: 65536

See this answer. Basically, you have a lot of imported libraries, and the combined number of methods in your app and all imported libraries has exceeded the limit.

Here is one thing you could try, pick and choose individual parts of Google Play Services that you need instead of importing the entire library. See documentation here.

So, if you only need Google Play Services for Maps, replace this:

compile 'com.google.android.gms:play-services:7.3.0'

With this:

compile 'com.google.android.gms:play-services-maps:7.3.0'

And hopefully that will get you below the limit!

Community
  • 1
  • 1
Daniel Nugent
  • 43,104
  • 15
  • 109
  • 137