好了,所以目前我做一个Android应用程序利用Java的 谷歌API表3.0版本和驱动API客户端库 ,我需要的应用读取从用户spreadhsheet推动帐户,并对其进行编辑。 下面的文件我已经包含在我的/ lib文件夹(Android Studio中1.1)以下的罐子。
dependencies { compile fileTree(include: ['*.jar'], dir: 'libs') compile 'com.android.support:appcompat-v7:21.0.3' compile 'com.google.android.gms:play-services:6.5.87' compile files('libs/google-api-client-1.19.1.jar') compile files('libs/google-api-client-android-1.19.1.jar') compile files('libs/google-api-services-drive-v2-rev158-1.19.1.jar') compile files('libs/google-http-client-1.19.0.jar') compile files('libs/google-http-client-android-1.19.0.jar') compile files('libs/google-http-client-gson-1.19.0.jar') compile files('libs/google-oauth-client-1.19.0.jar') compile files('libs/gson-2.1.jar') compile files('libs/jackson-core-2.1.3.jar') compile files('libs/jackson-core-asl-1.9.11.jar') compile files('libs/jsr305-1.3.9.jar') compile files('libs/protobuf-java-2.4.1.jar') compile files('libs/mail.jar') compile files('libs/jsr305.jar') compile files('libs/guava-11.0.2.jar') compile files('libs/gdata-spreadsheet-meta-3.0.jar') compile files('libs/gdata-spreadsheet-3.0.jar') compile files('libs/gdata-docs-meta-3.0.jar') compile files('libs/gdata-docs-3.0.jar') compile files('libs/gdata-core-1.0.jar') compile files('libs/gdata-client-meta-1.0.jar') compile files('libs/gdata-client-1.0.jar') compile files('libs/additionnal.jar') compile files('libs/activation.jar') }
当IM打字我的代码一切工作就好了,一切都appropiately进口,但是当我跑我的应用程序我得到这样的结果。
`What went wrong:
Execution failed for task ':app:dexDebug'.
> com.android.ide.common.internal.LoggedErrorException: Failed to run command:
C:\Users\Ricardo\AppData\Local\Android\sdk\build-tools\21.1.2\dx.bat --dex --output C:\Users\Ricardo\Google Drive\Development\Android\Updated\Private\Google_Fiasco\MyApplication\app\build\intermediates\dex\debug --input-list=C:\Users\Ricardo\Google Drive\Development\Android\Updated\Private\Google_Fiasco\MyApplication\app\build\intermediates\tmp\dex\debug\inputList.txt
Error Code:
2
Output:
UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dex.DexException: Multiple dex files define Ljavax/annotation/CheckForNull;
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)
e`<br>
现在有两件事情需要注意,当我提出两个单独的项目,一个实现电子表格API和其他驱动器API中没有发生错误。 只有当我实现在同一项目中两个API的即罐子从两个库合并时出现错误。 与罐子修修补补之后我发现,当两个错误仅发生jsr305.jar
& jsr305-1.3.9.jar
都包括在内。 看着这两个罐子我看到两个有CheckForNull.java
文件,错误消息引用的文件Multiple dex files define Ljavax/annotation/CheckForNull
。
所以我的问题: 我如何解决这个问题? 我想我必须排除它在我的依赖呢? 准确的指令,将不胜感激,或许对解决方案所做的解释。 另外最后一两件事有什么区别呢之间简单地把jar文件在我的/ lib文件夹和的build.gradle其添加到我的依赖性做什么呢? 这似乎并没有影响到任何东西。 删除要么jsr.jat文件的结果如下:
UNEXPECTED TOP-LEVEL EXCEPTION: com.android.dex.DexIndexOverflowException: method ID not in [0, 0xffff]: 65536 at com.android.dx.merge.DexMerger$6.updateIndex(DexMerger.java:502) at com.android.dx.merge.DexMerger$IdMerger.mergeSorted(DexMerger.java:277) at com.android.dx.merge.DexMerger.mergeMethodIds(DexMerger.java:491) at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:168) 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)