多个dex文件定义Landroid/support/v4/accessibilityservice/AccessibilityServiceInfoCompat与Gradle
当我运行多个dex文件定义Landroid/support/v4/accessibilityservice/AccessibilityServiceInfoCompat与Gradle,android,gradle,android-gradle-plugin,Android,Gradle,Android Gradle Plugin,当我运行/gradlew assembleDebug时,我得到: :app:dexDebug FAILED FAILURE: Build failed with an exception. * What went wrong: Execution failed for task ':app:dexDebug'. > com.android.ide.common.internal.LoggedErrorException: Failed to run command: /home
/gradlew assembleDebug
时,我得到:
:app:dexDebug FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:dexDebug'.
> com.android.ide.common.internal.LoggedErrorException: Failed to run command:
/home/grub/Main/android-sdk-linux/build-tools/19.1.0/dx --dex --num-threads=4 --output
合并类和JAR的列表:
UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dex.DexException: Multiple dex files define Landroid/support/v4/accessibilityservice/AccessibilityServiceInfoCompat$AccessibilityServiceInfoVersionImpl;
这与问题非常相似,问题应该存在于多个support-v4库中。我清理了build.gradle
:
repositories {
maven { url "http://dl.bintray.com/populov/maven" }
mavenCentral()
}
apply plugin: 'android'
android {
compileSdkVersion 19
buildToolsVersion '19.1.0'
defaultConfig {
minSdkVersion 9
targetSdkVersion 19
versionCode 8
versionName "2.1.17"
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:support-v4:20.+'
compile ('com.google.android.gms:play-services:5+'){
exclude group: 'com.android.support', module: 'support-v4'
}
compile(project(':libraries:com.typefacedwidgets')) {
exclude group: 'com.android.support', module: 'support-v4'
}
compile(project(':libraries:com.truepagerindicator')) {
exclude group: 'com.android.support', module: 'support-v4'
}
compile ('com.sothree.slidinguppanel:library:+'){
exclude group: 'com.android.support', module: 'support-v4'
}
compile ('com.github.chrisbanes.pulltorefresh:sample:2.1.1+'){
exclude group: 'com.google.android', module: 'support-v4'
}
compile 'com.thoughtworks.xstream:xstream:1.4.7'
compile 'com.squareup.retrofit:retrofit:1.6.1'
compile 'com.squareup.okhttp:okhttp-urlconnection:2.0.0'
compile 'com.squareup.okhttp:okhttp:2.0.0'
compile 'com.google.code.gson:gson:2.3'
compile 'de.greenrobot:eventbus:2.2.1'
}
}
要检查依赖项,我执行了/gradlew-q-依赖项,显示:
+--- com.android.support:support-v4:20.+ -> 20.0.0
| \--- com.android.support:support-annotations:20.0.0
+--- com.google.android.gms:play-services:5+ -> 5.2.08
+--- project :libraries:com.typefacedwidgets
+--- project :libraries:com.truepagerindicator
+--- com.sothree.slidinguppanel:library:+ -> 2.0.1
| \--- com.nineoldandroids:library:+ -> 2.4.0
+--- com.github.chrisbanes.pulltorefresh:sample:2.1.1+ -> 2.1.1
| +--- com.github.chrisbanes.pulltorefresh:library:2.1.1
| +--- com.github.chrisbanes.pulltorefresh:extra-listfragment:2.1.1
| | \--- com.github.chrisbanes.pulltorefresh:library:2.1.1
| \--- com.github.chrisbanes.pulltorefresh:extra-viewpager:2.1.1
| \--- com.github.chrisbanes.pulltorefresh:library:2.1.1
+--- com.thoughtworks.xstream:xstream:1.4.7
| +--- xmlpull:xmlpull:1.1.3.1
| \--- xpp3:xpp3_min:1.1.4c
+--- com.squareup.retrofit:retrofit:1.6.1
| \--- com.google.code.gson:gson:2.2.4 -> 2.3
+--- com.squareup.okhttp:okhttp-urlconnection:2.0.0
| \--- com.squareup.okhttp:okhttp:2.0.0
| \--- com.squareup.okio:okio:1.0.0
+--- com.squareup.okhttp:okhttp:2.0.0 (*)
+--- com.google.code.gson:gson:2.3
\--- de.greenrobot:eventbus:2.2.1
看起来应该没问题,但问题还是一样
更新:
问题出在apkLib依赖项中,并混淆了来自Gradle的msg。这个问题的解决就像把Android PullToRefresh放在Gradle的单独Android库项目中一样 问题出在apkLib依赖项中,并混淆了来自Gradle的消息。这个问题得到了解决,就像把Android PullToRefresh放到Gradle单独的Android库项目中一样。我刚刚重建了这个项目。解决了当我导入一些需要Google Play服务的LIB时,出现了这个错误
我刚从:
compile 'com.google.android.gms:play-services:6.5.87'
致:
现在,它构建ok在我的例子中,由于多个support-v4 jar文件,出现了类似的错误。为了解决这个问题,我进入了构建路径>配置构建路径>库选项卡。然后找到Android私有库并将其删除。清理项目并运行。@Satish Gadhave这是什么意思?我从其他依赖项中排除了所有其他support-v4库,只留下一个。但它是偷来的。可能的重复我认为它会变得混乱,因为您试图将示例作为依赖项引入,它对apklib有一个可传递的依赖项,而Gradle不知道如何处理apklib。另一方面,pulltorefresh的排除设置错误(com.android.support而不是com.google.android),但修复它并不能解决我提出的问题;当您试图依赖apklib时,Gradle应该提供更好的错误消息。
compile ('com.google.android.gms:play-services:6.5.87') {
exclude module: 'support-v4'
}