7 Replies Latest reply on Aug 17, 2017 2:03 AM by Etienne Boutry

    NoSuchFieldError : aimType

    Etienne Boutry

      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.

        • Re: NoSuchFieldError : aimType
          Darryn Campbell

          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.

          1 of 1 people found this helpful
            • Re: NoSuchFieldError : aimType
              Etienne Boutry

              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.

            • Re: NoSuchFieldError : aimType
              CHARITHA MALLAWAARACHCHI

              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.

              2 of 2 people found this helpful
              • Re: NoSuchFieldError : aimType
                Etienne Boutry

                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.