当我添加编译 'com.google.android.gms:play-services-wearable:6.5.87' 时,我的 gradle 构建失败
My gradle build fails when I add compile 'com.google.android.gms:play-services-wearable:6.5.87'
我在添加依赖项时尝试将 WearableListenerService 添加到我的手持设备 compile 'com.google.android.gms:play-services-wearable:6.5.87'
我在 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)
这是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'
}
你的问题是你正在编译两个相同的库:
compile files('libs/google-play-services-0.6.0-sources.jar')
compile 'com.google.android.gms:play-services-wearable:6.5.87'
您需要选择一个Google Play Services,最好是Maven Dependency 而不是.jar。
试试这个:
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'
}
我在添加依赖项时尝试将 WearableListenerService 添加到我的手持设备 compile 'com.google.android.gms:play-services-wearable:6.5.87'
我在 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)
这是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'
}
你的问题是你正在编译两个相同的库:
compile files('libs/google-play-services-0.6.0-sources.jar')
compile 'com.google.android.gms:play-services-wearable:6.5.87'
您需要选择一个Google Play Services,最好是Maven Dependency 而不是.jar。
试试这个:
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'
}