Android on Chrome OS: Getting (Side-) Loaded

This week, I will be blogging about how to test your app and what sorts of problems you may run into. Yesterday, I described how to get Android app support on a developer preview Chromebook.

Of course, invariably, you are going to want to test something other than your latest version of the app in the Play Store, or even perhaps a beta or other test version on the Play Store. You may want to test a build that is local to your development machine. You are used to doing that just by running your app from your IDE.

Those with wide Android developer experience may have run into Android equipment that did not support a direct adb connection, where you had to copy the APK over to the device and install it manually, rather than just run the app from an IDE. Right now, the developer preview Chromebooks work this way, so today, let’s look at how to enable side-loading.

Your instinctive reaction will be to copy the APK onto the Chromebook, perhaps to its Downloads folder, then try launching the APK from there. That will not work at present, as Chrome OS does not know what an APK file is.

Upon further reflection, you will realize that this is not all that surprising. So, you install a file manager Android app. You discover that the Downloads folder happens to be shared between the Android and Chrome OS worlds, so your APK is already available to you. Great! You try launching it, and you get the standard security dialog, pointing out that installation from unknown sources is disabled.

So, you go into Chrome OS’s Settings page, to get to Android’s Settings app, go into Security… and realize that the “Allow unknown sources” switch is completely missing.

And so, you cry in your beer (or other beverage of choice).

Google, on the whole, considers Chrome OS to be a closed environment, akin to Apple with iOS. You are expected to install your Android apps through the Play Store. However, there is a supported recipe for getting past this, though it is moderately annoying.

First, you need to enable Chrome OS developer mode. There is no direct analogue for this in the Android world. The closest match is enabling fastboot, perhaps as part of installing an Android developer preview ROM or some other custom ROM.

Unfortunately, the instructions for enabling developer mode are device-specific and arcane.

The Asus Chromebook Flip and the 2015 edition of the Chromebook Pixel share the same instructions:

  • First, find the hardware power button. On the Flip, this is on the left edge towards the front.

  • Next, shut down the device normally.

  • Then, hold down the Esc and Refresh keys, and while holding them down, press the power button to turn on the device. The Refresh key looks like a circular arrow and may be denoted as F3 on your keyboard. This brings up a “recovery screen”.

  • On the recovery screen, press Ctrl-D. This screen should prompt for confirmation, then reboot the device into developer mode.

From this point forward, your device will be developer mode. However, on subsequent reboots, now that recovery screen will always appear. There, you have three choices:

  1. Wait 30 seconds, in which case the device will continue its boot into developer mode

  2. Press Ctrl-D to skip the 30-second wait

  3. Follow the instructions on the screen to leave developer mode and return to normal operation

Also, since this involved a reboot, you may need to re-enable Android apps access in the Setting screen.

From here, you can then proceed to a fairly normal set-up-the-Android-device-for-development recipe:

  • Go into “About” and tap seven times on the “Build number” entry to enable developer settings

  • Go into “Developer options” and enable USB debugging (and anything else that you typically use)

  • Go into “Security” and enable “Unknown sources”

At this point, the Chrome OS device behaves more or less like a normal Android one, from the standpoint of side-loading apps. So long as you can arrange to install the APK from another Android app — such as opening the APK in a file manager app — you are set. You might consider using Google Drive, Dropbox, or similar apps to simplify the process a bit.

This, however, still does not give you adb access. So, there is no LogCat, no live debugging, and so on. Tomorrow, I will explain what few options we have in this area at present.

Nervous about how the newest version of Android affects your app? Consider subscribing, then asking questions in the office hours chats!