Dx 写入输出时遇到问题:已经准备好... - 控制台出错

Dx trouble writing output: already prepared... - Error in console

我需要在我的 android 应用程序中实现 braintree,这没有问题,但是当我将 braintree jar 文件复制到我的项目 libs 文件夹并导入必要的 类 时,我的应用程序崩溃了.

控制台中的完整错误消息:

Dx trouble writing output: already prepared [2015-06-18 15:31:42 - Dex Loader] Unable to execute dex: Multiple dex files define Landroid/support/annotation/AnimRes; [2015-06-18 15:31:42 - foto.studio] Conversion to Dalvik format failed: Unable to execute dex: Multiple dex files define Landroid/support/annotation/AnimRes;

我已经删除,重新导入所有内容两次,将 Eclipse 包更新到最新版本,并清理了我的项目。但是还是遇到了这个问题。当我删除 braintree 库时,我的应用 returns 恢复正常。

有人遇到同样的问题吗? 谢谢!

===解决方案===

最后转到 Android Studio。现在一切正常。

===更新===

正如@Luke 所建议的,我已将当前版本的 braintree 替换为 1.5.1,现在我的应用程序可以编译但 Braintree 不会初始化,并且我在 logcat 中收到以下错误:

06-18 18:17:44.581: W/dalvikvm(30518): VFY: unable to find class referenced in signature (Lcom/braintreepayments/api/data/BraintreeEnvironment;) 06-18 18:17:44.581: I/dalvikvm(30518): Could not find method com.braintreepayments.api.data.BraintreeEnvironment.getMerchantId, referenced from method com.braintreepayments.api.BraintreeApi.collectDeviceData 06-18 18:17:44.581: W/dalvikvm(30518): VFY: unable to resolve virtual method 10802: Lcom/braintreepayments/api/data/BraintreeEnvironment;.getMerchantId ()Ljava/lang/String; 06-18 18:17:44.581: D/dalvikvm(30518): VFY: replacing opcode 0x6e at 0x0000 06-18 18:17:44.581: E/dalvikvm(30518): Could not find class 'com.braintreepayments.api.data.BraintreeData', referenced from method com.braintreepayments.api.BraintreeApi.collectDeviceData 06-18 18:17:44.581: W/dalvikvm(30518): VFY: unable to resolve new-instance 1492 (Lcom/braintreepayments/api/data/BraintreeData;) in Lcom/braintreepayments/api/BraintreeApi; 06-18 18:17:44.581: D/dalvikvm(30518): VFY: replacing opcode 0x22 at 0x0000 06-18 18:17:44.586: E/dalvikvm(30518): Could not find class 'com.google.gson.Gson', referenced from method com.braintreepayments.api.BraintreeApi.getConfigurationString 06-18 18:17:44.586: W/dalvikvm(30518): VFY: unable to resolve new-instance 6903 (Lcom/google/gson/Gson;) in Lcom/braintreepayments/api/BraintreeApi; 06-18 18:17:44.586: D/dalvikvm(30518): VFY: replacing opcode 0x22 at 0x0004 06-18 18:17:44.586: I/TAG(30518): Datasource opened! 06-18 18:17:44.586: D/dalvikvm(30518): DexOpt: unable to opt direct call 0x2a2f at 0x02 in Lcom/braintreepayments/api/BraintreeApi;.collectDeviceData 06-18 18:17:44.586: D/dalvikvm(30518): DexOpt: unable to opt direct call 0xb169 at 0x06 in Lcom/braintreepayments/api/BraintreeApi;.getConfigurationString 06-18 18:17:44.586: E/dalvikvm(30518): Could not find class 'com.google.gson.Gson', referenced from method com.braintreepayments.api.models.ClientToken.fromString 06-18 18:17:44.586: W/dalvikvm(30518): VFY: unable to resolve new-instance 6903 (Lcom/google/gson/Gson;) in Lcom/braintreepayments/api/models/ClientToken; 06-18 18:17:44.586: D/dalvikvm(30518): VFY: replacing opcode 0x22 at 0x0017 06-18 18:17:44.591: D/dalvikvm(30518): DexOpt: unable to opt direct call 0xb169 at 0x19 in Lcom/braintreepayments/api/models/ClientToken;.fromString

这只是 1.6.1 和 1.6.0 中完整 jar 的问题。在这些版本中添加了一个新的可选依赖项,完整的 jar 将其拾取并编译。现在您可以使用 1.5.1,未来的版本将不会在完整的 jar 中包含 Google Play 服务。

当前未解决的问题:https://github.com/braintree/braintree_android/issues/35