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

341 views Asked by At
  • braintree-api-1.6.1-full.jar
  • android:minSdkVersion="14"
  • android:targetSdkVersion="18"

I need to implement braintree inside my android app which has no issues, but as I copy the braintree jar file, into my projects libs folder and import the necessary classes, my app crashes.

Full error message in console:

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;

I have removed, re imported everything twice, updated Eclipse packages too the latest version, and cleaned my project. But still got this issue. As I remove the braintree library my app returns to normal.

Did someone experience the same issue? Thanks!

=== Solution ===

Ended up by moving to Android Studio. Everything works as it should now.

=== UPDATE ===

As @Luke suggested, I have replaced the current version of braintree to 1.5.1, now my app compiles but Braintree won't initialize, and I get the following errors in 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

There are 1 answers

4
Luke On BEST ANSWER

This is only an issue in 1.6.1 and 1.6.0 with the full jar. A new optional dependency was added in these versions and the full jar picks it up and compiles it in. For now you can use 1.5.1 and a future release will not include Google Play Services in the full jar.

Currently open issue: https://github.com/braintree/braintree_android/issues/35