Developing for Zebra / Symbol Mobile Computers on Linux

8th February 2016 2 By darryncampbell

Introduction

This blog covers my experience developing a native Android application for Zebra / Symbol Mobile computers such as TC55, MC40 and TC70.  Unfortunately Linux is not a platform officially supported by Zebra for development but nonetheless it will work (with a few tweaks) so it’s worth sharing.

Distributions

According to the Android Studio download page, the only Linux distribution that software is tested on is Ubuntu Linux 64 bit.  Obviously developers are using other distributions to develop native Android apps so I tried on a variety of distros and will point out any discrepancies where I find them.

Pre-Requisites

In order to develop native Android apps for Zebra devices you need to follow the same pre-requisites as you would for any other hardware:

  • Java Development Kit from Oracle.  Android studio complained if I used a JDK from anywhere other than the official Oracle site so I recommend to download that one and add the /bin directory to your PATH.
  • Android Studio.  Though not strictly required for Android development it is the recommended IDE.
  • Android SDK.
    • If installing on a 64 bit machine you need to install the following libraries first for compatibility:
      • sudo apt-get install ia32-libs lib32ncurses5-dev lib32stdc++6
      • yum install glibc.i686 glibc-devel.i686 libstdc++.i686 zlib-devel.i686 ncurses-devel.i686 libX11-devel.i686 libXrender.i686 libXrandr.i686
    • Depending on your package installer, the former is documented on Google’s Linux installation instructions.
  • Add the following to your path:
    • Android SDK platform-tools (for adb)
    • Android SDK tools (for android.  Not strictly required but some 3rd party tools like cordova depend on this.)

EMDK Specific Pre-Requisites

  • To use Enterprise features on Zebra devices you’ll need API levels 16 and 19 installed.  At the time of writing, EMDK for Android 4.0 is the latest release and supports only those two targets, in the future EMDK will likely support additional targets and you should ensure the APIs for the supported levels are installed.
  • Download the EMDK for Android, I recommend the MAC installer as it has more manual steps and makes it easier to installed on Linux

Connecting devices via adb

Connecting most consumer devices to Ubuntu will ‘just work’ and the device will show up in $adb devices.  For some Zebra devices you will get a ‘no permissions’ when you enumerate the devices:

adb

This seems to be a problem with some device manufacturers, there are a couple of blogs / stack overflow posts (here and here) that address similar problems but I couldn’t find an elegant way to resolve this for myself.

If you have this issue then run the adb process as root and the device will be recognised successfully.  Interestingly, this was not a problem for me when I tried with Fedora or OpenSuse; it also recognised my TC70 successfully on Ubuntu so the issue may not affect you.

A couple of other gotchas:

  • Make sure you’re using the adb from platform-tools, if your distribution has an adb installed in /usr/bin I found this would never recognise my Zebra devices.
  • If you do need to run the adb process as root, ensure it is running before you run Android Studio.  That way Android Studio will pick up the rooted adb without needing to be run as root itself.

Installing EMDK on Linux

The EMDK gives API access to the enterprise hardware present on Zebra devices (scanner, card reader) as well as exposing the MX Android fortification layer adding security and other Enterprise functionality to the platform.

The EMDK comes as 3 components.

Download and unzip the EMDK for Mac to obtain the binaries described below.  You can follow the EMDK for Mac installation instructions for more detail but the Linux specific instructions are as follows:

1. EMDK profile wizard in Android Studio

Copy the com.symbol.emdk.wizard.intellijIdea folder from the downloaded <EMDK for Mac>/Android Studio directory into your Android Studio’s plugins directory.  In my case:

/home/darryn/programs/android-studio/plugins

2. EMDK Core functionality

Adding EMDK core functionality is less intuitive on Linux as the EMDK is hardcoded to only cater for Windows or Mac.  When loading the EMDK core package the following logic is executed:

If (PUBLIC environment variable exists)
      //  Assume Windows
      //  Read EMDK params from "%PUBLIC%/Symbol EMDK for Android/EMDKConfig.txt"
Else
     //  Assume Mac
     //  Read EMDK params from "/Users/Shared/Symbol EMDK for Android/EMDKConfig.txt"

It is therefore necessary for us to create the folder /Users/Shared which won’t exist by default on Linux.  Create the folder as root and then set the user as the owner, otherwise you will need to be root to load the EMDK:

$sudo mkdir /Users
$sudo mkdir /Users/Shared
$cd /Users
$sudo chown darryn Shared

Obviously replace ‘darryn’ above with your actual user.

Once the /Users/Shared directory has been created, copy the ‘Symbol EMDK for Android’ folder and all its contents into it.  To test you have done this successfully, launch Android Studio and from the EMDK menu bar select ‘About’.

Screenshot from 2016-02-08 10_21_58

3. SDK Addons

Copy the addon-symbol-emdk-v4.0_API-X folders from the downloaded <EMDK for Mac>/SDK directory into your Android SDK’s add-ons directory.  In my case:

/home/darryn/Android/Sdk/add-ons

After installing you should see the EMDK APIs listed in your SDK as illustrated below

addons

 

Building an EMDK native application

Screenshot_2016-02-08-10-16-36In order to test the EMDK has been successfully installed, the simplest thing to do is to run one of the EMDK samples:

As of EMDK 4.0 the EMDK samples are hosted on github on individual branches:

$git clone https://github.com/developer-zebra/samples-emdkforandroid-4_0.git
$cd samples-emdkforandroid-4_0
$git checkout ProfileWifiSample1

Open the sample in Android Studio, if you have installed the EMDK successfully then the sample should build and run on your Zebra mobile computer.

If you have problems, ensure the mobile computer is recognised by adb and the EMDK about screen displays successfully.

 

Targeting both Zebra and non-Zebra Android devices with the same application

Consider your application is required to also run on non-Zebra Android devices or you require APIs from a level unsupported in the current EMDK; you can still include EMDK functionality and it will only load on supported devices.

This is best detailed in the official blog.  I have run through this blog on Ubuntu, Fedora, Mint and OpenSuse and the application works as described for Linux development.