Debugging with Samsung KNOX

Fly Swatter

Samsung provides a container system called Samsung KNOX that provides a personal and work container.  Enterprise developers may realize that there will be some special steps they need to take in order to test applications in this scenario.  But if you are not an enterprise developer you may be thinking none of this will apply to you and that you’ll just do your development work in the personal container.  After all, that is how things worked on BlackBerry 10.  However, that isn’t the case here.  The developer restrictions imposed by Samsung KNOX apply to both the work and personal container.

The first issue you will encounter is the inability to enable USB Debugging.  To gain access to USB debugging you will need to request your BlackBerry Enterprise Server administrator to enable the “Allow debugging features” IT Policy.  Once granted, you’ll be able to enable USB debugging and connect to the device using Android Studio.  At this point, if you try to run an application on your device from Android Studio you’ll encounter the following errors:

Error Shown in Android Studio


Error Shown on Device

Security policy prevents installation of this application

When adb attempts to install an application, it tries to install it in every container on the device.  This means it’s trying to install in both the personal and work containers.  Since your application is not whitelisted for using within the KNOX container, the installation is blocked and the deployment fails.

You could work around this by copying the debug APK of your application to your device and install using a file browser application installed on the device.  This isn’t a great solution because of the manual steps and won’t allow you to use the debugging features of Android Studio either.

A better solution is to work together with your BlackBerry Enterprise Server administrator to have the application added to the BES and deployed your device.  For the purposes of testing and debugging, ensure that the debug APK file for your application is deployed.  You might be thinking that this sounds like a lot more work than copying the APK file manually, but going this route gives you a lot of added benefits.  Since the application is deployed into the KNOX container, it is now fully whitelisted to be installed from any source.  This means you can now go back to Android Studio and run/debug the application and deploy to your device.  You can also make updates to the application and test and debug them as well, so you won’t need to bug your administrator every time you have an update.  Just make sure you use the same developer key to sign the application updates.

Note:  Debugging in Samsung KNOX is available when using Samsung KNOX Full Control, where there is a personal and workspace area.  Samsung prevents the “Developer options” menu from appearing in the Android settings when using Samsung KNOX in workspace only mode, so you will not be able to enable developer options in workspace only mode.

Mark Sohm

About Mark Sohm

Senior Technical Solutions Manager on the Solution Architects team.

Mark Sohm joined BlackBerry in 2003 and currently works as a Senior Technical Solutions Manager on the Solutions Architects team. Mark Sohm has been helping developers create applications using BlackBerry technologies for over 15 years, starting way back with the very first BlackBerry JDK on BlackBerry OS 3.6 through to BlackBerry 10 and now Android with BlackBerry Dynamics and Android Enterprise.