Android Zebra SDK 2.2.4.0 - Dex Failure because of Gson

Hello,

I'm currently working with an app that was using the Android Zebra SDK 2.0.8.0 and would like to update to the latest (2.2.4.0). However, I now get a build error, showing a failure in the dexing of the apk:

* What went wrong:

Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'.

> java.lang.RuntimeException: java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex

I've tracked this down to the fact that my project includes the Gson library, version 2.8.1. I opened the contents of the ZebraSDK AAR and see that Gson 2.2.4 is being bundled in the libs folder. I suspect this is overriding the version of Gson I'm specifying in my gradle file due to a particular feature of the newer version now resulting in a compile error when including in the new Zebra SDK :

> Task :app:compileDebugJavaWithJavac

/.../ZebraTest/app/src/main/java/com/sample/zebratest/JsonModel.java:9: error: cannot find symbol

    @SerializedName(value="name1", alternate={"name_1"})

As you see here, the 'alternate' attribute of the SerializeName annotation is no longer available. Ordinarily if the SDK was a Maven dependency, one could simply add exclusions for the particular module and the version specified in the gradle file would take precedence, such as :

implementation('com.zebra.scannercontrol:barcode_scanner_library_v2.2.4.0@aar', {

  exclude group: 'com.google.code', module: 'gson'
})

However, I don't think it's possible to add exclusions on local file dependencies.

So far I've tried a few things:

1) Created a module from the AAR and attempted to exclude with library syntax, but it resulted in the same errors:

implementation (project(":barcode_scanner_library"), {

  exclude group: 'com.google.code', module: 'gson'
})

2) I've created a new version of the .aar by unzipping the existing aar and removing the gson jar file, and zipping it back up, but this also did not work - the app now fails to find any of the dependencies specified of the SDK, perhaps I've created the aar incorrectly.

I'm at a loss as to what to do next. Does anyone use the 2.2.4.0 Zebra SDK with newer versions of Gson successfully? Any help is appreciated.

tiger point
I am having same issue, were

I am having same issue, were you able to solve this ?

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Lydia Bittner
I got the same failure when i

I got the same failure when i updated Gradle.

Why does the Zebra SDK not work with a newer version than 2.14.1?

I tried several Methods to get it work. My gradle.build file looks like this

apply plugin: 'com.android.application'

android {

  compileSdkVersion 26
   buildToolsVersion "28.0.3"

   defaultConfig {

  applicationId "com.zebra.android.devdemo"
   minSdkVersion 15
   targetSdkVersion 26
   multiDexEnabled true
   }

  buildTypes {

  release {

  minifyEnabled false
   proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
   }

  }

  packagingOptions {

  exclude 'META-INF/LICENSE.txt'
   exclude 'META-INF/NOTICE.txt'
   exclude 'META-INF/NOTICE'
   exclude 'META-INF/LICENSE'
   exclude 'META-INF/DEPENDENCIES'
   }

}

dependencies {

  compile fileTree(include: ['*.jar'], dir: 'libs')

  compile 'com.android.support:appcompat-v7:26.1.0'
   compile 'com.android.support:design:26.1.0'
   compile 'com.android.support.constraint:constraint-layout:1.1.3'
}

When i delete aoocompat, design and teh constraint layout, the failure disappear but bluetooth dicovery won´t work.

I would be very thankful, if somebody explain me why it won´t work.

thank you

Lydia

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Lydia Bittner
i updated to apply plugin:

i updated to

apply plugin: 'com.android.application'

android {

  compileSdkVersion 26
   buildToolsVersion "28.0.3"

   defaultConfig {

  applicationId "com.zebra.android.devdemo"
   minSdkVersion 15
   targetSdkVersion 26
   multiDexEnabled true
   }

  buildTypes {

  release {

  minifyEnabled false
   proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
   }

  }

  packagingOptions {

  exclude 'META-INF/LICENSE.txt'
   exclude 'META-INF/NOTICE.txt'
   exclude 'META-INF/NOTICE'
   exclude 'META-INF/LICENSE'
   exclude 'META-INF/DEPENDENCIES'
   }

}

dependencies {

  api fileTree(include: ['*.jar'], dir: 'libs')

  implementation 'com.android.support:appcompat-v7:26.1.0'
   implementation 'com.android.support:design:26.1.0'
   implementation 'com.android.support.constraint:constraint-layout:1.1.3'
}

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Alfred Kallas
Any Solution for this problem ?

Hello, i am facing the same problem did you guys find any solution for this problem ?

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Log in to post comments