简体   繁体   中英

My gradle build fails when I add compile 'com.google.android.gms:play-services-wearable:6.5.87'

I am trying to add WearableListenerService to my hand held when I add the dependency compile 'com.google.android.gms:play-services-wearable:6.5.87' I get this error in the gradle build

Error:Execution failed for task ':app:dexDebug'.
> com.android.ide.common.internal.LoggedErrorException: Failed to run command:
    /Users/jshultz/android-sdks/build-tools/21.1.2/dx --dex --no-optimize --output /Users/jshultz/Documents/workspace/MayDay/app/build/intermediates/dex/debug --input-list=/Users/jshultz/Documents/workspace/MayDay/app/build/intermediates/tmp/dex/debug/inputList.txt
  Error Code:
    2
  Output:
    UNEXPECTED TOP-LEVEL EXCEPTION:
    com.android.dex.DexException: Multiple dex files define Landroid/support/v4/accessibilityservice/AccessibilityServiceInfoCompatIcs;
        at com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:596)
        at com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:554)
        at com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:535)
        at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:171)
        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)

Here is the build.gradle

apply plugin: 'com.android.application'

android {
    compileSdkVersion 21
    buildToolsVersion "21.1.2"

    defaultConfig {
        applicationId "com.mayday.md"
        minSdkVersion 18
        targetSdkVersion 21
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
        }
    }
}

dependencies {
    compile files('libs/crashlytics.jar')
    compile files('libs/cup-v1.0.0.jar')
    compile files('libs/support-v4-r12.jar')
    compile files('libs/gson-2.2.4.jar')
    compile files('libs/google-play-services-0.6.0-sources.jar')
    compile 'com.google.android.gms:play-services-wearable:6.5.87'
}

Your problem is your are compiling two libraries that are the same:

compile files('libs/google-play-services-0.6.0-sources.jar')
compile 'com.google.android.gms:play-services-wearable:6.5.87'

You need to chose one Google Play Services , preferably the Maven Dependency and not the .jar.

Try this:

dependencies {
    compile files('libs/crashlytics.jar') // couldn't find maven
    compile files('libs/cup-v1.0.0.jar')  // couldn't find maven
    compile 'com.android.support:support-v4:21.0.3'
    compile 'com.google.code.gson:gson:2.3.1'
    compile 'com.google.android.gms:play-services-wearable:6.5.87'
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM