4 Replies Latest reply on Jun 25, 2015 10:17 AM by Matt Kunze

    Trouble linking EMDK to existing project

    Matt Kunze

      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-forums/android-blogs/blog/2015/02/10/developing-emdk-apps-with-android-studio-10x

       

      * 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 <uses-permission android:name="com.symbol.emdk.permission.EMDK" /> and <uses-library android:name="com.symbol.emdk" />

      * 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