我在添加依赖项compile 'com.google.android.gms:play-services-wearable:6.5.87'
时尝试将WearableListenerService添加到我的手中我在gradle构建中出现此错误
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'
}
答案 0 :(得分:1)
您的问题是您正在编译两个相同的库:
compile files('libs/google-play-services-0.6.0-sources.jar')
compile 'com.google.android.gms:play-services-wearable:6.5.87'
您需要选择一个 Google Play服务,最好是Maven依赖,而不是.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'
}