UDI
UDI

Reputation: 1602

Json SErializer

My code is build but when i try to run the code following exception occurs:

com.android.ide.common.internal.LoggedErrorException: Failed to run command:
C:\adt-bundle-windows-x86_64-20140624\sdk\build-tools\20.0.0\dx.bat --dex --no-optimize --output 

Error Code: 2

Output:

UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dex.DexException: Multiple dex files define Lcom/google/gson/JsonSerializer;
    at com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:594)
    at com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:552)

I read a few of the similar problems but most of them were working after adding exclude clause or adding transitive statement. I'm using gradle 2.2 and The problem still exists . My dependency block as follows:

dependencies {
compile project(':volley')
compile project(':jumioSDK')
compile project(':parallaxScroll')
compile 'com.android.support:appcompat-v7:19.1.0'
compile 'com.google.android.gms:play-services:6.1.71'
compile ('org.springframework.android:spring-android-rest-template:1.0.1.RELEASE')
compile ('org.codehaus.jackson:jackson-mapper-asl:1.9.13')
compile ('org.codehaus.jackson:jackson-core-asl:1.9.13')
compile 'joda-time:joda-time:2.3'
compile (project(':AndroidIBeaconLibrary-1.0'))
compile (project(':SOLOMOExchangeSdk-1.0'))
compile 'com.google.code.gson:gson:2.3.1'
}

the dependency chart

+--- version1.7_solomo:volley:unspecified

+--- version1.7_solomo:jumioSDK:unspecifie

|    \--- LOCAL: jumio_netswipe_sdk_2.0.3.jar

+--- version1.7_solomo:parallaxScroll:unspecified

+--- com.android.support:appcompat-v7:19.1.0

|    \--- com.android.support:support-v4:20.0.0

|         \--- LOCAL: internal_impl-20.0.0.jar

+--- com.google.android.gms:play-services:6.1.71

|    \--- com.android.support:support-v4:20.0.0

|         \--- LOCAL: internal_impl-20.0.0.jar

+--- version1.7_solomo:AndroidIBeaconLibrary-1.0:unspecified

\--- version1.7_solomo:SOLOMOExchangeSdk-1.0:unspecified

     +--- LOCAL: estimote-sdk-preview.jar

     +--- LOCAL: gson-2.2.2.jar

     +--- LOCAL: jmockit-no-junit.jar

     +--- LOCAL: signalr-client-sdk-1.0.jar

     \--- LOCAL: signalr-client-sdk-android.jar

Upvotes: 0

Views: 656

Answers (1)

Rafa Araujo
Rafa Araujo

Reputation: 344

  • Update your libs/aars projects version with the latest version
  • Rather than using build.gradle to import your libs/aars instead put into /libs folder

Here I was having this problem and my solution was removing "gson-2.2.4.jar" from /libs and importing by gradle, using

compile 'com.google.code.gson:gson:2.2.4'

instead of

compile files('libs/gson-2.2.4.jar')

Works like a charm.

Upvotes: 1

Related Questions