Trouble linking EMDK to existing project

M Matt Kunze 3 years 5 months ago
166 2 0

I'm trying to link the EMDK framework to an existing application and running into linker issues when the application runs. I've been following the basic steps from the 'Import EMDK lib JAR as a Module' section on this page: https://developer.motorolasolutions.com/community/android/android-forum…
 
* I created a new application in Android Studio with a default activity
* Added the com.symbol.emdk.jar library to the libs folder
* Updated AndroidManifest.xml to include and
* Added code to the main activity to access the EMDKManager and attach a listener
 
The project compiles and deploys to a device, but when I run it fails with:
 
06-25 16:12:46.177  13410-13410/? W/dalvikvm﹕ Class resolved by unexpected DEX: Lcom/example/matt/emdklink/MainActivity;(0x415f1df8):0x58ee7000 ref [Lcom/symbol/emdk/EMDKManager$EMDKListener;] Lcom/symbol/emdk/EMDKManager$EMDKListener;(0x415f1df8):0x5160a000
06-25 16:12:46.177  13410-13410/? W/dalvikvm﹕ (Lcom/example/matt/emdklink/MainActivity; had used a different Lcom/symbol/emdk/EMDKManager$EMDKListener; during pre-verification)
06-25 16:12:46.177  13410-13410/? W/dalvikvm﹕ Link of class 'Lcom/example/matt/emdklink/MainActivity;' failed
06-25 16:12:46.177  13410-13410/? W/dalvikvm﹕ threadid=1: thread exiting with uncaught exception (group=0x40c69438)
06-25 16:12:46.177  13410-13410/? E/AndroidRuntime﹕ FATAL EXCEPTION: main
    java.lang.IllegalAccessError: Class ref in pre-verified class resolved to unexpected implementation
            at dalvik.system.DexFile.defineClass(Native Method)
            at dalvik.system.DexFile.loadClassBinaryName(DexFile.java:211)
            at dalvik.system.DexPathList.findClass(DexPathList.java:315)
            at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:58)
            at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
            at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
            at android.app.Instrumentation.newActivity(Instrumentation.java:1056)
            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2023)
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2133)
            at android.app.ActivityThread.access$600(ActivityThread.java:142)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
            at android.os.Handler.dispatchMessage(Handler.java:99)
            at android.os.Looper.loop(Looper.java:137)
            at android.app.ActivityThread.main(ActivityThread.java:4895)
            at java.lang.reflect.Method.invokeNative(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:511)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:789)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:556)
            at dalvik.system.NativeStart.main(Native Method)
           
The device runtime is deployed on the handheld (TC55), the samples applications from the EMDK work. Ultimately we need this to work using the Cordova command line build tools, which is why I'm trying to link to the library directly and not rely on the Android Studio-specific runtime configuration.
 
I've pushed the project files here https://github.com/MattKunze/EmdkLink as well

Please Register or Login to post a reply

2 Replies

M Matt Kunze

I think I've figured this out - the dependency settings for com.symbol.emdk.jar need to be Provided instead of Compile. That part was cut off from the screenshot on the blog post mentioned above:

This changes the entry in build.gradle from
compile files('libs/com.symbol.emdk.jar')
to
provided project(':com.symbol.emdk')

And the library needs to be added as a separate module instead of just adding the jar file as a dependency

M Matt Kunze

I have also tried removing the jar file from the project and changing the SDK version for the module to 'Symbol Technologies, Inc.:EMDK 3.0 (API 19):19' and it produces the same error

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