,当我运行 - 我得到这个错误>应用程序为Android Studio中Android Studio中多dex文件所gradle这个错误
UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dex.DexException: Multiple dex files define Lcom/google/common/annotations/Beta;
...
而且这里的Android应用程序是gradlew -q的输出:应用:依赖
+--- project :shared
+--- com.google.api-client:google-api-client:1.19.0
| +--- com.google.oauth-client:google-oauth-client:1.19.0
| | +--- com.google.http-client:google-http-client:1.19.0
| | | +--- com.google.code.findbugs:jsr305:1.3.9
| | | \--- org.apache.httpcomponents:httpclient:4.0.1
| | | +--- org.apache.httpcomponents:httpcore:4.0.1
| | | +--- commons-logging:commons-logging:1.1.1
| | | \--- commons-codec:commons-codec:1.3
| | \--- com.google.code.findbugs:jsr305:1.3.9
| +--- com.google.http-client:google-http-client-jackson2:1.19.0
| | +--- com.google.http-client:google-http-client:1.19.0 (*)
| | \--- com.fasterxml.jackson.core:jackson-core:2.1.3
| \--- com.google.guava:guava-jdk5:13.0
+--- com.google.http-client:google-http-client-gson:1.19.0
| \--- com.google.code.gson:gson:2.1
+--- com.google.api-client:google-api-client-android:1.19.0
| +--- com.google.api-client:google-api-client:1.19.0 (*)
| \--- com.google.http-client:google-http-client-android:1.19.0
| \--- com.google.http-client:google-http-client:1.19.0 (*)
+--- com.google.http-client:google-http-client-android:1.19.0 (*)
+--- com.google.guava:guava:14.0.+ -> 14.0.1
+--- project :backend-appengine
| \--- com.google.api-client:google-api-client-android:1.19.0 (*)
+--- com.android.support:appcompat-v7:20.0.0
| \--- com.android.support:support-v4:20.0.0
| \--- com.android.support:support-annotations:20.0.0
+--- com.google.android.gms:play-services:5.0.89
\--- com.google.maps.android:android-maps-utils:0.3.+ -> 0.3.1
下面是从的build.gradle
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile project(':shared')
// Add the Google API client library.
compile(group: 'com.google.api-client', name: 'google-api-client', version: '1.19.0') {
// Exclude artifacts that the Android SDK/Runtime provides.
exclude(group: 'com.google.guava') //-- !!! this does not seem to work !!!
exclude(group: 'xpp3', module: 'xpp3')
exclude(group: 'org.apache.httpcomponents', module: 'httpclient')
exclude(group: 'junit', module: 'junit')
exclude(group: 'com.google.android', module: 'android')
exclude(group: 'com.google.http-client', module: 'google-http-client')
}
compile('com.google.http-client:google-http-client-gson:1.19.0') {
exclude module: 'httpclient'
exclude(group: 'com.google.http-client', module: 'google-http-client')
}
compile(group: 'com.google.api-client', name: 'google-api-client-android', version: '1.19.0') {
exclude(group: 'com.google.android.gms', module: 'play-services')
exclude group: 'com.google.guava', module: 'guava-jdk5'
}
compile(group: 'com.google.http-client', name: 'google-http-client-android', version: '1.19.0') {
exclude(group: 'com.google.android', module: 'android')
}
// This is used by the Google HTTP client library.
compile(group: 'com.google.guava', name: 'guava', version: '14.0.+')
//-- endpoints
dependencies {
compile project(path: ':backend-appengine', configuration: 'android-endpoints')
}
compile 'com.android.support:appcompat-v7:20.0.0'
compile ('com.google.android.gms:play-services:5.0.89') {
exclude(group: 'com.android.support', module: 'support-v4')
}
compile ('com.google.maps.android:android-maps-utils:0.3.+') {
exclude(group: 'com.google.android.gms', module: 'play-services')
}
}
感谢kcoppock。我认为你一定是对的,但不管我如何尝试,我都无法从com.google.api-client编译中排除guava模块。为什么会这样?我使用: compile(group:'com.google.api-client',name:'google-api-client',version:'1.19.0'){ exclude(group:'com.google.guava' ) } 和其他排除的可能性我可以想到,但它永远不会被排除 – aez 2014-09-23 01:21:59
然而,kcoppock,我知道你是正确的,因为我评论了第二番石榴编译(14.0),我可以建立。但是,我仍然希望能够排除第一个番石榴模块,但是评分似乎不允许。任何想法为什么? – aez 2014-09-23 01:26:11
你确定你改变了你的依赖*完全*如上所示?我只是自己试了一下,没有我的排除路线,它没有像你的那样组装。使用排除行,它会成功。 – kcoppock 2014-09-23 01:35:04