0
好的我知道關於這個話題有很多關於SO的問題和答案。我讀了很多,結果通常是一樣的,你有相互依賴的衝突。有些人甚至建議運行gradlew依賴來獲得一棵樹。奇怪的是,這個命令顯示所有的依賴都運行相同的版本號。任何幫助非常感謝,我很茫然。下面找到我的命令輸出,來自AndroidStudio和app.gradle文件的錯誤。我還應該提到,只有在嘗試調試到設備時纔會出現此錯誤,而不是在gradle構建和同步時發生。定義了多個dex文件
錯誤
UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dex.DexException: Multiple dex files define Landroid/support/annotation/AnimRes;
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:502)
at com.android.dx.command.dexer.Main.runMonoDex(Main.java:334)
at com.android.dx.command.dexer.Main.run(Main.java:277)
at com.android.dx.command.dexer.Main.main(Main.java:245)
at com.android.dx.command.Main.main(Main.java:106)
app.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
applicationId "com.company.company"
minSdkVersion 17
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile 'com.android.support:appcompat-v7:23.0.1'
compile 'com.android.support:design:23.0.1'
}
命令輸出
:app:dependencies
------------------------------------------------------------
Project :app
------------------------------------------------------------
_debugAndroidTestApk - ## Internal use, do not manually configure ##
No dependencies
_debugAndroidTestCompile - ## Internal use, do not manually configure ##
No dependencies
_debugApk - ## Internal use, do not manually configure ##
+--- com.android.support:appcompat-v7:23.0.1
| \--- com.android.support:support-v4:23.0.1
| \--- com.android.support:support-annotations:23.0.1
\--- com.android.support:design:23.0.1
+--- com.android.support:support-v4:23.0.1 (*)
\--- com.android.support:appcompat-v7:23.0.1 (*)
_debugCompile - ## Internal use, do not manually configure ##
+--- com.android.support:appcompat-v7:23.0.1
| \--- com.android.support:support-v4:23.0.1
| \--- com.android.support:support-annotations:23.0.1
\--- com.android.support:design:23.0.1
+--- com.android.support:support-v4:23.0.1 (*)
\--- com.android.support:appcompat-v7:23.0.1 (*)
_debugUnitTestApk - ## Internal use, do not manually configure ##
No dependencies
_debugUnitTestCompile - ## Internal use, do not manually configure ##
No dependencies
_releaseApk - ## Internal use, do not manually configure ##
+--- com.android.support:appcompat-v7:23.0.1
| \--- com.android.support:support-v4:23.0.1
| \--- com.android.support:support-annotations:23.0.1
\--- com.android.support:design:23.0.1
+--- com.android.support:support-v4:23.0.1 (*)
\--- com.android.support:appcompat-v7:23.0.1 (*)
_releaseCompile - ## Internal use, do not manually configure ##
+--- com.android.support:appcompat-v7:23.0.1
| \--- com.android.support:support-v4:23.0.1
| \--- com.android.support:support-annotations:23.0.1
\--- com.android.support:design:23.0.1
+--- com.android.support:support-v4:23.0.1 (*)
\--- com.android.support:appcompat-v7:23.0.1 (*)
_releaseUnitTestApk - ## Internal use, do not manually configure ##
No dependencies
_releaseUnitTestCompile - ## Internal use, do not manually configure ##
No dependencies
androidJacocoAgent - The Jacoco agent to use to get coverage data.
Download https://jcenter.bintray.com/org/jacoco/org.jacoco.agent/0.7.4.201502262128/org.jacoco.agent-0.7.4.201502262128.pom
\--- org.jacoco:org.jacoco.agent:0.7.4.201502262128
androidJacocoAnt - The Jacoco ant tasks to use to get execute Gradle tasks.
Download https://jcenter.bintray.com/org/jacoco/org.jacoco.ant/0.7.4.201502262128/org.jacoco.ant-0.7.4.201502262128.pom
Download https://jcenter.bintray.com/org/jacoco/org.jacoco.report/0.7.4.201502262128/org.jacoco.report-0.7.4.201502262128.pom
\--- org.jacoco:org.jacoco.ant:0.7.4.201502262128
+--- org.jacoco:org.jacoco.core:0.7.4.201502262128
| \--- org.ow2.asm:asm-debug-all:5.0.1
+--- org.jacoco:org.jacoco.report:0.7.4.201502262128
| +--- org.jacoco:org.jacoco.core:0.7.4.201502262128 (*)
| \--- org.ow2.asm:asm-debug-all:5.0.1
\--- org.jacoco:org.jacoco.agent:0.7.4.201502262128
androidTestApk - Classpath packaged with the compiled 'androidTest' classes.
No dependencies
androidTestCompile - Classpath for compiling the androidTest sources.
No dependencies
androidTestProvided - Classpath for only compiling the androidTest sources.
No dependencies
androidTestWearApp - Link to a wear app to embed for object 'androidTest'.
No dependencies
apk - Classpath packaged with the compiled 'main' classes.
No dependencies
archives - Configuration for archive artifacts.
No dependencies
compile - Classpath for compiling the main sources.
+--- com.android.support:appcompat-v7:23.0.1
| \--- com.android.support:support-v4:23.0.1
| \--- com.android.support:support-annotations:23.0.1
\--- com.android.support:design:23.0.1
+--- com.android.support:support-v4:23.0.1 (*)
\--- com.android.support:appcompat-v7:23.0.1 (*)
debugApk - Classpath packaged with the compiled 'debug' classes.
No dependencies
debugCompile - Classpath for compiling the debug sources.
No dependencies
debugProvided - Classpath for only compiling the debug sources.
No dependencies
debugWearApp - Link to a wear app to embed for object 'debug'.
No dependencies
default - Configuration for default artifacts.
No dependencies
default-mapping - Configuration for default mapping artifacts.
No dependencies
default-metadata - Metadata for the produced APKs.
No dependencies
provided - Classpath for only compiling the main sources.
No dependencies
releaseApk - Classpath packaged with the compiled 'release' classes.
No dependencies
releaseCompile - Classpath for compiling the release sources.
No dependencies
releaseProvided - Classpath for only compiling the release sources.
No dependencies
releaseWearApp - Link to a wear app to embed for object 'release'.
No dependencies
testApk - Classpath packaged with the compiled 'test' classes.
No dependencies
testCompile - Classpath for compiling the test sources.
No dependencies
testDebugApk - Classpath packaged with the compiled 'testDebug' classes.
No dependencies
testDebugCompile - Classpath for compiling the testDebug sources.
No dependencies
testDebugProvided - Classpath for only compiling the testDebug sources.
No dependencies
testDebugWearApp - Link to a wear app to embed for object 'testDebug'.
No dependencies
testProvided - Classpath for only compiling the test sources.
No dependencies
testReleaseApk - Classpath packaged with the compiled 'testRelease' classes.
No dependencies
testReleaseCompile - Classpath for compiling the testRelease sources.
No dependencies
testReleaseProvided - Classpath for only compiling the testRelease sources.
No dependencies
testReleaseWearApp - Link to a wear app to embed for object 'testRelease'.
No dependencies
testWearApp - Link to a wear app to embed for object 'test'.
No dependencies
wearApp - Link to a wear app to embed for object 'main'.
No dependencies
感謝您的回答!我實現了這兩個代碼更改,但我仍然留下了相同的問題。有沒有機會使用我正在使用的gradle版本? (1.4.0-beta6) – Kyle
後續行動:結合您的兩條建議並升級到1.5.0-beta1可以解決問題。 – Kyle
使用compile'com.android.support:appcompat-v7:23.0.1'和 compile'com.android.support:design:23.0.1'不會產生問題。 –