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.
NoSuchFieldError : aimType// Expert user has replied. |
4 Replies
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.
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.
GMS is Google Mobile Services (Android – Google Mobile Services ). If your device has Chrome for example, you have GMS.
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.