NoSuchFieldError : aimType

Good afternoon,

 

I am developping an app running on a TC8000 and using the EMDK library to read bar codes.

Everything was working fine until I tried setting the aimType, using this code :

 

ScannerConfig config = scanner.getConfig();

ScannerConfig.AimType aimType =  ScannerConfig.AimType.TIMED_HOLD;

config.readerParams.readerSpecific.laserSpecific.aimType = aimType;

config.readerParams.readerSpecific.laserSpecific.aimTimer = 500;

scanner.setConfig(config);

 

which resulted in the following exception being thrown :

 

java.lang.NoSuchFieldError: No instance field aimType of type Lcom/symbol/emdk/barcode/ScannerConfig$AimType; in class Lcom/symbol/emdk/barcode/ScannerConfig$ReaderParams$ReaderSpecific$LaserSpecific; or its superclasses (declaration of 'com.symbol.emdk.barcode.ScannerConfig$ReaderParams$ReaderSpecific$LaserSpecific' appears in /system/framework/com.symbol.emdk.jar)

 

When editing code, Android Studio confirms the presence of an aimType field in the LaserSpecific class. I tried using Java reflection to check the declared fields of LaserSpecific at runtime and indeed, aimType is missing. Additionnally, the ScannerConfig.AimType class is missing at runtime, but is present in the apk.

 

I checked the documentation and AimType seems to be a recent addition. So far, my guess is that the runtime ignores the packaged EMDK dependency and runs another one instead. I have no idea why this is happening. Additionnaly, the DWDemo / DataWedge apps on the same TC8000 make use of this setting, proving it is possible on this machine. I tried to change the scope from provided to compile in the Gradle dependencies, to no effect. Removing the emdk5 product flavor did not help either.

 

Here is the build.gradle file :

 

apply plugin: 'com.android.application'

 

android {

    compileSdkVersion 25

    buildToolsVersion "25.0.3"

    defaultConfig {

        applicationId "com.bonduelle.agreoscan.agreoscan"

        minSdkVersion 22

        targetSdkVersion 25

        versionCode 1

        versionName "1.0"

        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"

    }

    buildTypes {

        release {

            minifyEnabled false

            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'

        }

    }

    productFlavors {

        emdk6 {

            targetSdkVersion 23

            minSdkVersion 21 // EMDK 6.0 supports as far back as KitKat (19)

            versionCode 30000 + android.defaultConfig.versionCode

            versionNameSuffix "-emdk6"

        }

    }

}

 

dependencies {

    provided fileTree(include: ['com.symbol.emdk.jar'], dir: 'D:\\Android\\sdk\\add-ons\\addon-symbol_emdk-symbol-23\\libs')

    compile fileTree(exclude: ['com.symbol.emdk.jar'], dir: 'libs')

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

    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {

        exclude group: 'com.android.support', module: 'support-annotations'

    })

    compile 'com.android.support:appcompat-v7:25.3.1'

    compile 'com.android.support.constraint:constraint-layout:1.0.2'

    compile 'com.mcxiaoke.volley:library:1.0.19'

    testCompile 'junit:junit:4.12'

}

 

Has anyone encountered a similar problem, or has an idea of how to fix it?

 

Thanks in advance.

Anonymous (not verified)
Hi,The TC8000 has an Imager,

Hi,

The TC8000 has an Imager, not a 'laser' scaner, please use ScannerConfig.ReaderParams.ReaderSpecific.ImagerSpecific (app API)  ImagerSpecific rather than LaserSpecific.  I do not have a device handy to confirm this I'm afraid but hopefully that is your issue.

Thanks,

Darryn.

Vote: 
Vote up!
Vote down!

Points: 1

You voted ‘up’


Etienne Boutry
Good morning,Thank you for

Good morning,

Thank you for your answer. I changed my code to :

ScannerConfig config = scanner.getConfig();

config.readerParams.readerSpecific.imagerSpecific.aimType = ScannerConfig.AimType.TIMED_HOLD;

config.readerParams.readerSpecific.imagerSpecific.aimTimer = 500;

scanner.setConfig(config);

But it did not fix the problem. The exception is :

java.lang.NoClassDefFoundError: Failed resolution of: Lcom/symbol/emdk/barcode/ScannerConfig$AimType;

<snip>

Caused by: java.lang.ClassNotFoundException: Didn't find class "com.symbol.emdk.barcode.ScannerConfig$AimType" on path: DexPathList[[zip file "/system/framework/com.symbol.emdk.jar", zip file "/data/app/app.package-2/base.apk", zip file "/data/app/app.package-2/split_lib_dependencies_apk.apk", zip file "/data/app/app.package-2/split_lib_slice_0_apk.apk", zip file "/data/app/app.package-2/split_lib_slice_1_apk.apk", zip file "/data/app/app.package-2/split_lib_slice_2_apk.apk", zip file "/data/app/app.package-2/split_lib_slice_3_apk.apk", zip file "/data/app/app.package-2/split_lib_slice_4_apk.apk", zip file "/data/app/app.package-2/split_lib_slice_5_apk.apk", zip file "/data/app/app.package-2/split_lib_slice_6_apk.apk", zip file "/data/app/app.package-2/split_lib_slice_7_apk.apk", zip file "/data/app/app.package-2/split_lib_slice_8_apk.apk", zip file "/data/app/app.package-2/split_lib_slice_9_apk.apk"],nativeLibraryDirectories=[/vendor/lib, /system/lib]]

Thanks for telling me I should use imagerSpecific, not knowing this would probably have been the next headache.

The error message has changed, but I think the problem is still the same. In the previous version, the AimType class was missing already. I think the message changed because the virtual machine tried to find the AimType class before it looked for the aimType filed this time. Still no clue what is happening. I suspect the class loader looks in the native library directories before it looks inside the apk.

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Anonymous (not verified)
Hmmm... Is your TC8000 up to

Hmmm... Is your TC8000 up to date?  If you have a maintenance agreement (or warranty) you can download the updates from TC8000 Touch Computer Support & Downloads | Zebra  .  The implementation of the scanner logic resides in the device rather than the SDK jar file which is why I suggest ensuring your device is up to date.  This is covered in the 'Device Updates' section of the release notes (https://www.zebra.com/content/dam/zebra_new_ia/en-us/software/developer-tools/emdk-for-android/emdk-android-0604098-rele… ) .  Or perhaps there is some issue with your build configuration (though it looks OK from what you have posted above), maybe try the SDK Add-on as demonstrated in the sample (GitHub - Zebra/samples-emdkforandroid-6_4 at BarcodeSample1 ) .

Vote: 
Vote up!
Vote down!

Points: 1

You voted ‘up’


CHARITHA MALLAW...
Hi,As Darryn pointed out, if

Hi,

As Darryn pointed out, if the EMDK service in the "device" is 6.0.xx or older, you will face this and the corrective action is to update devices. They have introduced in EMDK 6.4.

Thanks,

Charith.

Vote: 
Vote up!
Vote down!

Points: 1

You voted ‘up’


Etienne Boutry
Thanks to both of you for

Thanks to both of you for your help. The EMDK version on the TC8000 is the 6.0.6.306. I thought AimType was supported on 6.0 and above.

I cannot update the device for now as the one I have is a borrowed one. I will have to wait until our order is delivered. With any luck, the new ones will have the latest version installed. By the way, what is GMS? The updates are marked as GMS and Non-GMS and I cannot tell the difference.

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Anonymous (not verified)
GMS is Google Mobile Services

GMS is Google Mobile Services (Android – Google Mobile Services ).  If your device has Chrome for example, you have GMS.

Vote: 
Vote up!
Vote down!

Points: 1

You voted ‘up’


Etienne Boutry
I'm now calling the TC800

I'm now calling the TC800 "the barcode reader that can run Chrome".

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Log in to post comments