关于gradle:Android Studio 1.0 RC 4构建错误

Android Studio 1.0 RC 4 Build Error

我尽力从intelij导入一个项目,我得到这个很长的错误,我无法理解。 我尝试了"无效并重启"并得到了同样的错误。 我不知道如果我的任何构建文件与此错误相关,如果您有任何建议请告诉我,我将使用它进行更新。

错误:任务':app:dexDebug'的执行失败。

com.android.ide.common.internal.LoggedErrorException: Failed to run command:
C:\Users
ick\AppData\Local\Android\android-sdk\build-tools\20.0.0\dx.bat --dex --no-optimize --output C:\Users
ick\AndroidStudioProjects
ameThatPlaneQuiz\app\build\intermediates\dex\debug C:\Users
ick\AndroidStudioProjects
ameThatPlaneQuiz\app\build\intermediates\classes\debug C:\Users
ick\AndroidStudioProjects
ameThatPlaneQuiz\app\build\intermediates\pre-dexed\debug\support-annotations-21.0.2-0a182725e9aa175cb2c9765c57055aaa824304e6.jar C:\Users
ick\AndroidStudioProjects
ameThatPlaneQuiz\app\build\intermediates\pre-dexed\debug\picasso-2.1.1-ca3ca17668b6992af9c01975b92b9bf572784f6a.jar C:\Users
ick\AndroidStudioProjects
ameThatPlaneQuiz\app\build\intermediates\pre-dexed\debug\libGoogleAnalyticsV2-767507628f16b98644c7df4c6626869f426ce4e7.jar C:\Users
ick\AndroidStudioProjects
ameThatPlaneQuiz\app\build\intermediates\pre-dexed\debug\internal_impl-21.0.2-a8cad4df1b726255aab2a982204a5f72da2f18c3.jar C:\Users
ick\AndroidStudioProjects
ameThatPlaneQuiz\app\build\intermediates\pre-dexed\debug\amazon-ads-5.4.46-736982c75f8a8e92a0ad571df866edd9f053f48a.jar C:\Users
ick\AndroidStudioProjects
ameThatPlaneQuiz\app\build\intermediates\pre-dexed\debug\android-support-v4-570a9308b85abcb60e3a8fe6408341585e0080ba.jar C:\Users
ick\AndroidStudioProjects
ameThatPlaneQuiz\app\build\intermediates\pre-dexed\debug\classes-886dcf9785070a0ce74d9b194160c2ed98e7f5a6.jar C:\Users
ick\AndroidStudioProjects
ameThatPlaneQuiz\app\build\intermediates\pre-dexed\debug\android-support-v7-47c2bab1cd06319a40ed131420476fad110b3621.jar C:\Users
ick\AndroidStudioProjects
ameThatPlaneQuiz\app\build\intermediates\pre-dexed\debug\classes-cde05798e7e54ac95eab6032df408c4025bb501c.jar C:\Users
ick\AndroidStudioProjects
ameThatPlaneQuiz\app\build\intermediates\pre-dexed\debug\libGoogleAnalyticsServices-4179946d7621a48fc3cc005840f233ec074f4ad9.jar C:\Users
ick\AndroidStudioProjects
ameThatPlaneQuiz\app\build\intermediates\pre-dexed\debug\classes-e97fdf43369bbf65731abaad5e4fd840d08f90a7.jar
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:594)
at com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:552)
at com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:533)
at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:170)
at com.android.dx.merge.DexMerger.merge(DexMerger.java:188)
at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:439)
at com.android.dx.command.dexer.Main.runMonoDex(Main.java:287)
at com.android.dx.command.dexer.Main.run(Main.java:230)
at com.android.dx.command.dexer.Main.main(Main.java:199)
at com.android.dx.command.Main.main(Main.java:103)

将构建工具更改为21.1.1会导致此错误:

错误:任务':app:dexDebug'的执行失败。

com.android.ide.common.internal.LoggedErrorException: Failed to run command:
C:\Users
ick\AppData\Local\Android\android-sdk\build-tools\21.1.1\dx.bat --dex --no-optimize --output C:\Users
ick\AndroidStudioProjects
ameThatPlaneQuiz\app\build\intermediates\dex\debug --input-list=C:\Users
ick\AndroidStudioProjects
ameThatPlaneQuiz\app\build\intermediates\tmp\dex\debug\inputList.txt
Error Code:
2
Output:
UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dex.DexException: Multiple dex files define Lcom/google/analytics/tracking/android/AnalyticsClient;
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:302)
at com.android.dx.command.dexer.Main.run(Main.java:245)
at com.android.dx.command.dexer.Main.main(Main.java:214)
at com.android.dx.command.Main.main(Main.java:106)


1
2
com.android.dex.DexException: Multiple dex files define
com/google/analytics/tracking/android/AnalyticsClient

该错误是由于包含Google Analytics库的多个依赖项(jar,aars或项目)造成的。这可能是因为:

  • 有时,中间构建文件处于奇怪/错误状态,特别是如果您正在调整依赖项或更改构建工具而不进行清理。转到Build-> clean project,或运行`./gradlew clean',然后再次尝试构建。
  • 您两次引用相同的库(例如,您包含Google Analytics jar,并且您正在使用gradle / maven工件)。删除其中一个。
  • 最不可能的是 - 两个不同的库/依赖项实际上包含Google Analytics。您可以通过使用JD-GUI等实用程序手动检查jar / aar文件以查看它们包含的包,或者您可以更轻松地在项目的build文件夹(通常为build/intermediates)中查看Android Studio以查看是否您发布的错误中引用的包有重复的条目。
  • 如果#1不起作用,我首先要审核所有项目的依赖项。一般来说,我远离项目结构对话框,只需手动编辑.gradle文件。我建议将.gradle文件的编辑版本添加到您的问题中。