11 Replies Latest reply on Dec 13, 2015 7:36 PM by Josh Fischer

    How to reference Symbol EMDK while targeting Lollipop or Higher

    Javier Hernandez

      Is there a way of using the symbol EMDK libraries while compiling the Android project with API 23 ?

       

      I have a working sample with EMDK scanning with a build.gradle file that reads like this:

      android {

        compileSdkVersion 'Symbol Technologies, Inc.:EMDK 3.1 (API 16):16'
         buildToolsVersion "23.0.1"

       

      When compiling with the Symbol EMDK 3.1 API16 it works fine.

       

      In my case, I target not only Enterprise units, so I am always compiling with the latest Sdk available.

      So I am trying to change the sdk to 23 and add the com.symbol.emdk.jar as a dependency of the project but my app fail to run.

      compileSdkVersion 23
      buildToolsVersion "23.0.1"

       

      Is there a way to add a reference to the EMDK and still target the latest SDK ?

        • Re: How to reference Symbol EMDK while targeting Lollipop or Higher
          Pietro Maggi

          Hi Javier,

          at this moment the EMDK is supported only on API Level 16 or 19, however you can compile it with the latest SDK manually changing the app.gradle file,

           

          to use the SDK you like:

           

          compileSdkVersion 23
          buildToolsVersion "23.0.1"


          The key point is to include the com.symbol.emdk.jar library (that you need to copy in your libs folder from the EMDK setup folder) as a provided lib, not to be compiled in your project

           

          dependencies {

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

            compile 'com.android.support:appcompat-v7:23.0.1'
             provided fileTree(dir: 'libs', include: ['com.symbol.emdk.jar'])

          }

           

           

          ~Pietro

            • Re: How to reference Symbol EMDK while targeting Lollipop or Higher
              Javier Hernandez

              Copy, pasted and like Ace Ventura says "Like a glove"

              My app is loading, now I need to write make the full implementation, should not take too long and out to production in no time.

              Thanks a lot.

                • Re: How to reference Symbol EMDK while targeting Lollipop or Higher
                  Pietro Maggi

                  Good,

                  "Like a glove!" :-)

                   

                  Can you mark the question as answered?

                   

                  thanks

                  ~Pietro

                    • Re: How to reference Symbol EMDK while targeting Lollipop or Higher
                      Josh Fischer

                      Hi Pietro,

                       

                      I copied the com.symbol.emdk.jar into the libs folder.  I am trying to build a simple application using this library (actually the advanced scanner tutorial).  Everything is fine with the application until I try to reference any part of the EMDK library.  The stack trace that prints on the Activity load is below...

                       

                      FATAL EXCEPTION: main

                                                                                           Process: com.somecompany.shelfman, PID: 6909

                                                                                           java.lang.NoClassDefFoundError: com.somecompany.shelfman.activities.ScannerActivity

                                                                                               at com.somecompany.shelfman.activities.TaskSelectionActivity$1.onClick(TaskSelectionActivity.java:39)

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

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

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

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

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

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

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

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

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

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

                                                                                               at dalvik.system.NativeStart.main(Native Method)

                       

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

                       

                      The Activity referencing the EMDK libraries starts as

                       

                      import com.symbol.emdk.EMDKManager;
                      import com.symbol.emdk.EMDKManager.EMDKListener;
                      import com.symbol.emdk.barcode.BarcodeManager;
                      import com.symbol.emdk.barcode.ScanDataCollection;
                      import com.symbol.emdk.barcode.Scanner;
                      import com.symbol.emdk.barcode.Scanner.DataListener;
                      import com.symbol.emdk.barcode.Scanner.StatusListener;
                      import com.symbol.emdk.barcode.ScannerInfo;
                      import com.symbol.emdk.barcode.StatusData;

                      import java.util.List;

                      public class ScannerActivity extends AppCompatActivity implements EMDKListener,
                         StatusListener, DataListener, CompoundButton.OnCheckedChangeListener{

                       

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

                       

                      My build.gradle looks like....

                       

                      apply plugin: 'com.android.application'
                      apply from: '../jacoco.gradle'

                      android {

                        compileSdkVersion 23
                         buildToolsVersion "23.0.1"

                         defaultConfig {

                         applicationId "com.somecompany.shelfman"
                         minSdkVersion 19
                         targetSdkVersion 23
                         versionCode 1
                         versionName "1.0"
                         }

                        buildTypes {

                        release {

                         minifyEnabled false
                         proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
                         }

                        debug {

                         testCoverageEnabled = true
                         }

                        }

                      }

                       

                      dependencies {

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

                        testCompile 'junit:junit:4.12'
                         testCompile 'org.mockito:mockito-core:1.+'
                         testCompile 'org.robolectric:robolectric:3.0'
                         testCompile 'org.hamcrest:hamcrest-core:1.2.1'
                         compile 'com.android.support:appcompat-v7:23.0.1'
                         compile 'com.android.support:design:23.1.1'
                         provided fileTree(dir: 'libs', include: ['com.symbol.emdk.jar'])

                      }

                       

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

                      If I take reference to the emdk library out the activity loads as I would expect. Any ideas?

                        • Re: How to reference Symbol EMDK while targeting Lollipop or Higher
                          Pietro Maggi

                          Hi Josh,

                          do you've a reference to the EMDK library and the EMDK permission listed in the Manifest.xml?

                           

                          <uses-permission android:name="com.symbol.emdk.permission.EMDK" />  

                          <uses-library android:name="com.symbol.emdk" />

                           

                          As explained in the EMDK documentation.

                          Or you can give a look at this post and the linked sample app:

                          Building Zebra's EMDK project using SDK Platform 23 - Tales from an old nibble

                           

                          Ciao

                          ~Pietro

                            • Re: How to reference Symbol EMDK while targeting Lollipop or Higher
                              Josh Fischer

                              Sorry I forgot to mention the manifest...

                               

                              When I include <uses-library android:name="com.symbol.emdk" /> The application crashes when I try to deploy  it to my TC70.  Message states:

                               

                              Application Installation Failed

                               

                              Installation failed with message

                              INSTALL_FAILED_MISSING_SHARED_LIBRARY

                               

                              Then some other lines of text mentioning uninstalling an existing version of the application, however, there is no previous version installed.  If I comment the <uses-library> line out the application still compiles until I load the Activity referencing the emdk library.  I should also note that I also have pasted the <uses-permission> tag as well.  See manifest below:

                               

                              <?xml version="1.0" encoding="utf-8"?>
                              <manifest package="com.somecompany.shelfman"
                                 xmlns:android="http://schemas.android.com/apk/res/android">
                                <uses-permission android:name="com.symbol.emdk.permission.EMDK" />


                                <application
                                      android:allowBackup="true"
                                      android:icon="@mipmap/ic_launcher"
                                      android:label="@string/app_name"
                                      android:supportsRtl="true"
                                      android:theme="@style/AppTheme">

                                <uses-library android:name="com.symbol.emdk"/>
                                <activity
                                      android:name=".activities.LoginActivity"
                                      android:label="@string/app_name"
                                      android:screenOrientation="portrait"
                                      android:theme="@style/AppTheme.NoActionBar">
                                </activity>
                                <activity
                                      android:name=".activities.SplashScreenActivity"
                                      android:label="@string/title_activity_splash_screen"
                                      android:screenOrientation="portrait"
                                      android:theme="@style/SplashTheme">
                                     <intent-filter android:label="@string/app_name">
                                          <action android:name="android.intent.action.MAIN"/>

                                          <category android:name="android.intent.category.LAUNCHER"/>
                                     </intent-filter>
                                </activity>
                                <activity
                                     android:name=".activities.TaskSelectionActivity"
                                      android:label="@string/title_activity_task_selection"
                                      android:theme="@style/AppTheme.NoActionBar">
                                </activity>
                                <activity android:name=".activities.ScannerActivity"
                                      android:label="ScannerActivity"
                                      android:theme="@style/AppTheme.NoActionBar">
                                </activity>
                                </application>

                              </manifest>