Android Zebra SDK 2.2.4.0 - Dex Failure because of Gson

T Thomas Jones 3 years 7 months ago
39 2 0

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 dexI'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.

Please Register or Login to post a reply

2 Replies

A Alfred Kallas

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

M Martin Eberl

Any response from Zebra yet?

I'm using SDK Version 2.3.2 and i'm trying to do something a little different

implementation (project(':external_libraries:zebra_v2.3.2.0')) {
exclude group: 'com.zebra.scannercontrol'
}

Error message starts with:
Program type already present: com.zebra.scannercontrol.R$bool
at com.android.builder.dexing.D8DexArchiveMerger.getExceptionToRethrow(D8DexArchiveMerger.java:131)

CONTACT
Can’t find what you’re looking for?