Using EMDK in Cordova Plugin

// Expert user has replied.
F Frank Koenigstein 2 years 11 months ago
109 3 0

How can I use the emdk api within a cordova plugin?
I added com.symbol.jar to the lib folder of my plugin:
 
    PowerManager     PowerManager Plugin     phonegap,cordova,PowerManager,dff                                                                                                                                                                                                                                                  
Then building an apk works fine. But when the plugin is executed the following error is thrown:
 
06-22 16:22:07.639: W/dalvikvm(8575): Class resolved by unexpected DEX: Lcom/dff/cordova/plugin/powermanager/PowerManagerPlugin;(0x419475c0):0x5b666000 ref [Lcom/symbol/emdk/EMDKManager$EMDKListener;] Lcom/symbol/emdk/EMDKManager$EMDKListener;(0x419475c0):0x5b625000 06-22 16:22:07.639: W/dalvikvm(8575): (Lcom/dff/cordova/plugin/powermanager/PowerManagerPlugin; had used a different Lcom/symbol/emdk/EMDKManager$EMDKListener; during pre-verification) 06-22 16:22:07.639: I/dalvikvm(8575): Failed resolving Lcom/dff/cordova/plugin/powermanager/PowerManagerPlugin; interface 706 'Lcom/symbol/emdk/EMDKManager$EMDKListener;' 06-22 16:22:07.639: W/dalvikvm(8575): Link of class 'Lcom/dff/cordova/plugin/powermanager/PowerManagerPlugin;' failed 06-22 16:22:07.639: W/System.err(8575): java.lang.ClassNotFoundException: com.dff.cordova.plugin.powermanager.PowerManagerPlugin 06-22 16:22:07.639: W/System.err(8575): at java.lang.Class.classForName(Native Method) 06-22 16:22:07.649: W/System.err(8575): at java.lang.Class.forName(Class.java:251) 06-22 16:22:07.649: W/System.err(8575): at java.lang.Class.forName(Class.java:216) 06-22 16:22:07.649: W/System.err(8575): at org.apache.cordova.PluginManager.instantiatePlugin(PluginManager.java:487) 06-22 16:22:07.649: W/System.err(8575): at org.apache.cordova.PluginManager.getPlugin(PluginManager.java:167) 06-22 16:22:07.659: W/System.err(8575): at org.apache.cordova.PluginManager.exec(PluginManager.java:120) 06-22 16:22:07.659: W/System.err(8575): at org.apache.cordova.CordovaBridge.jsExec(CordovaBridge.java:59) 06-22 16:22:07.659: W/System.err(8575): at org.apache.cordova.engine.SystemExposedJsApi.exec(SystemExposedJsApi.java:41) 06-22 16:22:07.659: W/System.err(8575): at com.android.org.chromium.base.SystemMessageHandler.nativeDoRunLoopOnce(Native Method) 06-22 16:22:07.659: W/System.err(8575): at com.android.org.chromium.base.SystemMessageHandler.handleMessage(SystemMessageHandler.java:24)06-22 16:22:07.659: W/System.err(8575): at android.os.Handler.dispatchMessage(Handler.java:102) 06-22 16:22:07.659: W/System.err(8575): at android.os.Looper.loop(Looper.java:136) 06-22 16:22:07.659: W/System.err(8575): at android.os.HandlerThread.run(HandlerThread.java:61) 06-22 16:22:07.669: W/System.err(8575): Caused by: java.lang.NoClassDefFoundError: com/dff/cordova/plugin/powermanager/PowerManagerPlugin 
Is there a way to include com.symbol.jar for compiling but not for dexing?

Please register or login to post a reply

3 Replies

K Kanagal Raj Ramaswamy

The com.symbol.emdk.jar which gets installed during the EMDK installer can be used only for compiling applications. This stubbed version and does not contain the actual source. So you should never copy the com.symbol.emdk.jar into your applications lib folder.

Choices are:
1. If you are using Android Studio or Eclipse and want use Android API 16 or 19, select the EMDK API in the Android or Eclipse to build the application in the build target.

2. If you are using the Android Studio or Eclipse, but use google API and EMDK together, select on of the add-on in the build target and add the other as external library.

3. If you are using the Build script to build your project, you can use like
LOCAL_JAVA_LIBRARIES := com.symbol.emdk
LOCAL_PREBUILT_STATIC_JAVA_LIBRARIES := libemdk:com.symbol.emdk/com.symbol.emdk.jar

4. if you are using the gradle to build your project, then use the com.symbol.emdk.jar in dependencies of your gradle file as below:
You need to add the below to your gradle file, where EMDKSDK specifies folder where your com.symbol.emdk.jar is located. In this sample I am using the relative path.
dependencies {    compile fileTree(include: ['*.jar'], dir: 'libs')
    compile fileTree("..\\..\\EMDKSDK\\com.symbol.emdk.jar")}

The overall comment is use com.symbol.emdk.jar for compiling application, never deploy this as part of your application. This way the application does not need to recompile there apps when the EMDK team release news patches and fixes. Installing the EMDK OS update will deploy the corresponding run times on the device and specifying   in your app tells the android to dynamically use the library on device.

P Pietro Francesco Maggi

Hi Frank,
one of the things that you need to keep in mind is that you need to reference the com.symbol.emdk.jar library NOT INCLUDE IT!

so, for example, using gradle, you can have something like this in your configuration if you put the com.symbol.emdk.jar library in the libs folder:

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'], exclude: ['com.symbol.emdk.jar'])
    compile 'com.android.support:appcompat-v7:21.0.3'
    provided files('./libs/com.symbol.emdk.jar')
}

best regards
~Pietro

V Vedsatx Saddvv

Are you using eclipse or Android studio to build your application?

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