App crashing when trying to add the EMDK as a dependency.

I have setup the EMDK for Android Studio as "Importing EMDK lib Jar as a Module" by following the steps at the following url EMDK For Android Setup (Android Studio1.0.x) - Zebra Technologies Techdocs

Build .gradle contains the following :

compile project(':com.symbol.emdk')

Crash reason :

Check failed: called != nullptr int java.lang.Enum.ordinal() com.symbol.emdk.EMDKManager$FEATURE_TYPE[]

-----------------

When the gradle is changed to

provided project(':com.symbol.emdk')

It is unable to import com.symbol.emdk.barcode.Scanner;

-------------

unable to import if the gradle is changed to

dependencies {
provided fileTree
(include: ['com.symbol.emdk.jar'], dir: '/Users/<YOUR USERNAME>/Library/Android/sdk/add-ons/addon-symbol_emdk-symbol-19/libs')
compile fileTree
(exclude: ['com.symbol.emdk.jar'], dir: 'libs')

--------------------

​@

Sandeep rathod
Appropriate Permissions and

Appropriate Permissions and Library added in Manifest file

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Anonymous (not verified)
Hi, those instructions are

Hi, those instructions are quite old... I suggest you add EMDK to your gradle build file as described at EMDK for Android Programming Practices - Zebra Technologies TechDocs

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Sandeep rathod
Hi,App is crashing, please

Hi,

App is crashing, please find the attached crash log

E/UncaughtException: java.lang.NoClassDefFoundError: Failed resolution of: Lcom/xxx/Activity/AcActivity;

        at com.xxx.x.Adapter.CustomAdapter$1.onClick(CustomAdapter.java:341)

        at android.view.View.performClick(View.java:4780)

        at android.view.View$PerformClick.run(View.java:19866)

        at android.os.Handler.handleCallback(Handler.java:739)

        at android.os.Handler.dispatchMessage(Handler.java:95)

        at android.os.Looper.loop(Looper.java:135)

        at android.app.ActivityThread.main(ActivityThread.java:5254)

        at java.lang.reflect.Method.invoke(Native Method)

        at java.lang.reflect.Method.invoke(Method.java:372)

        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)

        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)

     Caused by: java.lang.ClassNotFoundException: Didn't find class "com.xxx.x.Activity.AcActivity" on path: DexPathList[[zip file "/system/framework/com.google.android.maps.jar", zip file "/data/app/com.xxx.x-1/base.apk"],nativeLibraryDirectories=[/vendor/lib, /system/lib]]

        at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)

        at java.lang.ClassLoader.loadClass(ClassLoader.java:511)

        at java.lang.ClassLoader.loadClass(ClassLoader.java:469)

        at com.xxx.x.Adapter.CustomAdapter$1.onClick(CustomAdapter.java:341)

        at android.view.View.performClick(View.java:4780)

        at android.view.View$PerformClick.run(View.java:19866)

        at android.os.Handler.handleCallback(Handler.java:739)

        at android.os.Handler.dispatchMessage(Handler.java:95)

at android.os.Looper.loop(Looper.java:135)

        at android.app.ActivityThread.main(ActivityThread.java:5254)

        at java.lang.reflect.Method.invoke(Native Method)

        at java.lang.reflect.Method.invoke(Method.java:372)

        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)

        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)

     Suppressed: java.lang.NoClassDefFoundError: com.xxx.x.Activity.AcActivity

        at dalvik.system.DexFile.defineClassNative(Native Method)

        at dalvik.system.DexFile.defineClass(DexFile.java:226)

        at dalvik.system.DexFile.loadClassBinaryName(DexFile.java:219)

        at dalvik.system.DexPathList.findClass(DexPathList.java:321)

        at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:54)

          ... 13 more

     Suppressed: java.lang.ClassNotFoundException: com.xxxx.Activity.AcActivity

        at java.lang.Class.classForName(Native Method)

        at java.lang.BootClassLoader.findClass(ClassLoader.java:781)

        at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)

        at java.lang.ClassLoader.loadClass(ClassLoader.java:504)

          ... 12 more

     Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack available

-----

Build.gradle file

provided fileTree(include: ['com.symbol.emdk.jar'], dir: 'C:\\Users\\xxx\\AppData\\Local\\Android\\sdk\\add-ons\\addon-symbol_emdk-symbol-26\\libs')

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

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Anonymous (not verified)
Hi, that error indicates the

Hi, that error indicates the system cannot find com.google.android.maps.jar.  Please note that if you are using a non-GMS device then maps will not be present - that could be the cause.

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Sandeep rathod
Now,Im getting crash on the

Now,Im getting crash on the following line

    Caused by: java.lang.ClassNotFoundException: Didn't find class "com.symbol.emdk.barcode.Scanner$DataListener" on path: DexPathList[[zip file "/system/framework/com.google.android.maps.jar", zip file "/data/app/com.smartkargo.shipper-1/base.apk"],nativeLibraryDirectories=[/data/app/com.smartkargo.shipper-1/lib/x86, /system/lib, /vendor/lib]]

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Sandeep rathod
Similar error on another demo

Similar error on another demo

06-11 11:49:34.453 15834-15834/? E/AndroidRuntime: FATAL EXCEPTION: main

    Process: com.zebra.scannerlifecycle, PID: 15834

    java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.zebra.scannerlifecycle/com.zebra.scannerlifecycle.MainActivity}: java.lang.ClassNotFoundException: Didn't find class "com.zebra.scannerlifecycle.MainActivity" on path: DexPathList[[zip file "/data/app/com.zebra.scannerlifecycle-1/base.apk"],nativeLibraryDirectories=[/data/app/com.zebra.scannerlifecycle-1/lib/x86, /system/lib, /vendor/lib]]

        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2567)

        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2726)

        at android.app.ActivityThread.-wrap12(ActivityThread.java)

        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1477)

        at android.os.Handler.dispatchMessage(Handler.java:102)

        at android.os.Looper.loop(Looper.java:154)

        at android.app.ActivityThread.main(ActivityThread.java:6119)

        at java.lang.reflect.Method.invoke(Native Method)

        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)

        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)

     Caused by: java.lang.ClassNotFoundException: Didn't find class "com.zebra.scannerlifecycle.MainActivity" on path: DexPathList[[zip file "/data/app/com.zebra.scannerlifecycle-1/base.apk"],nativeLibraryDirectories=[/data/app/com.zebra.scannerlifecycle-1/lib/x86, /system/lib, /vendor/lib]]

        at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)

        at java.lang.ClassLoader.loadClass(ClassLoader.java:380)

        at java.lang.ClassLoader.loadClass(ClassLoader.java:312)

        at android.app.Instrumentation.newActivity(Instrumentation.java:1078)

        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2557)

        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2726)

        at android.app.ActivityThread.-wrap12(ActivityThread.java)

        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1477)

        at android.os.Handler.dispatchMessage(Handler.java:102)

        at android.os.Looper.loop(Looper.java:154)

        at android.app.ActivityThread.main(ActivityThread.java:6119)

        at java.lang.reflect.Method.invoke(Native Method)

        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)

        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)

    Suppressed: java.lang.NoClassDefFoundError: Failed resolution of: Lcom/symbol/emdk/barcode/Scanner$DataListener;

        at java.lang.VMClassLoader.findLoadedClass(Native Method)

        at java.lang.ClassLoader.findLoadedClass(ClassLoader.java:742)

        at java.lang.ClassLoader.loadClass(ClassLoader.java:362)

        ... 12 more

     Caused by: java.lang.ClassNotFoundException: Didn't find class "com.symbol.emdk.barcode.Scanner$DataListener" on path: DexPathList[[zip file "/data/app/com.zebra.scannerlifecycle-1/base.apk"],nativeLibraryDirectories=[/data/app/com.zebra.scannerlifecycle-1/lib/x86, /system/lib, /vendor/lib]]

        at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)

        at java.lang.ClassLoader.loadClass(ClassLoader.java:380)

        at java.lang.ClassLoader.loadClass(ClassLoader.java:312)

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Anonymous (not verified)
Which device are you using? 

Which device are you using?  Can you please try the barcode sample to see if that works? samples-emdkforandroid-6_8/BarcodeSample1 at master · Zebra/samples-emdkforandroid-6_8 · GitHub

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Sandeep rathod
Moto G2 . This device doesn't

Moto G2 . This device doesn't support emdk.So we have added the following check.

if (Build.MANUFACTURER.contains("Zebra Technologies") || Build.MANUFACTURER.contains("Motorola Solutions")) {

}.

But the app crashes even before the it reaches the following control.

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Anonymous (not verified)
Aha!  I thought you were

Aha!  I thought you were having the problem on a Zebra device.  On non-Zebra devices you will get a crash whenever you instantiate a class that implements EMDK.EMDKListener, I work around this in one of my personal projects by proxying the calls to EMDK through a class that does not instantiate EMDK.EMDKListener: WakeLock_WifiLock_Exerciser/EMDKProxy.java at master · darryncampbell/WakeLock_WifiLock_Exerciser · GitHub  

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Sandeep rathod
How to implement the

How to implement the following method of Scanner.DataListener.

It is crashing if we implement the following.

AcActivity extends LifecycleActivity implements  Scanner.DataListener,

@Overide

public void onData(ScanDataCollection scanDataCollection) {

  

}

Implement only if the EMDK device is present.

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Sandeep rathod
I do have multiple activities

I do have multiple activities .  How do I get the events the scanned barcode data in respective activities ?

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Anonymous (not verified)
You may find it easier to use

You may find it easier to use DataWedge for your application data capture given the above thread however there is a sample application described at   documenting how you can use multiple activities with the EMDK.

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Log in to post comments