EMDK user library optional load for Android

1k views Asked by At

I have an application to read barcodes. This application can be used with an Zebra device with its integrated reader connected with API but also with a common Android device with a camera.

The problem is that I get this error

Installation did not succeed.
The application could not be installed: INSTALL_FAILED_MISSING_SHARED_LIBRARY

When installing the application in a non-Zebra device.

It is possible to set the library as optional to avoid the double compilation (with/without third paty library)?

2

There are 2 answers

1
Darryn Campbell On BEST ANSWER

Yes, you can specify the library as optional and you also need to ensure you do not instantiate a class that extends the EMDKListener on a non-Zebra device or you will get a crash. I have an example of an app that uses the EMDK on Zebra devices but also runs on non-Zebra devices, https://github.com/darryncampbell/WakeLock_WifiLock_Exerciser/tree/master/WakeLock_WifiLock_Exerciser. It does not use the EMDK for scanning but hopefully you can see the principle - the MainActivity.java has a test whether the EMDK is available

0
sturi On

I resolve same issue.

First modify AndroidManifest as suggested <uses-library android:name="com.symbol.emdk" **android:required="false"** />

I create a class that instantiate EMDK using code suggested in https://github.com/darryncampbell/WakeLock_WifiLock_Exerciser/blob/master/WakeLock_WifiLock_Exerciser/app/src/main/java/com/darryncampbell/wakelockexample/EMDKInterface.java

In my Android Application class I create a method that check EMDK is available

    public boolean isEMDKAvailable()
  {
    try
    {
        EMDKInterface test = new EMDKInterface(ContextAppManager.context);
        return true;
    }
    catch (NoClassDefFoundError e)
    {
        return false;
    }
}

But my main problem was being able to use the same activity. The only solution I found is to extend the activity and insert all the things related to Zebra SDK.

During the creation of the new intent towards the activity it is necessary to check EMDK to instantiate the correct class

Intent i = new Intent(getBaseContext(),  ContextAppManager.getInstance().isEMDKAvailable() ? CheckTicketZebraActivity.class : CheckTicketActivity.class);
startActivity(i);