The CommonsBlog


Android on Chrome OS: adb Access

The Android-on-Chrome OS documentation was updated recently to include instructions on connecting to your Chrome OS device through adb from your development machine. This will allow you to run apps on the Chrome OS device from Android Studio, for example.

Unfortunately, the instructions have bugs, and I don’t know where to report those bugs. So, here is what worked for me, using their instructions as a starting point.

Get the Basics Working

Follow the instructions in my “Getting Started” and “Getting (Side-) Loaded” blog posts to get your Chrome OS device up to date and in developer mode, plus get the Android subsystem working.

Configure the Chrome OS Device

The official instructions ask you to use “virtual terminal 2” and log in as root to make changes to Chrome OS. I could not get this to work; even their supplied default root password was not recognized.

Instead, I used Ctrl-Alt-T to open crosh. From there, I executed the shell command to get to bash. And, for their documented root commands, I used sudo.

So, if you get to bash using those steps, execute the following statements:

sudo /usr/libexec/debugd/helpers/dev_features_rootfs_verification
sudo reboot

This will reboot your Chrome OS device, requiring you to go through the whole Play Store acceptance/login process again.

Then, go back into bash, and execute:

sudo /usr/libexec/debugd/helpers/dev_features_ssh

This enables an SSH daemon and presumably makes corresponding adjustments to the iptables-based firewall.

Find Your Chrome OS IP Address

The official instructions tell you to do this “from ChromeOS settings”, without actually explaining how that is done.

Go into Settings (e.g., tap on the time/WiFi/battery/account bar in the lower-right, then tap the gear icon). Towards the top of the Settings page, there will be an “Internet connection” section. If you are using WiFi, tap on the “Wi-Fi network” item, then tap on the WiFi network that you are using. That should bring up a three-tab dialog with details about this network connection. The middle tab — Network — will show your IP address. Make note of this.

Configure Your Development Machine

UPDATE 2016-07-19: The process described in this section is no longer needed.

On your computer that you use for Android development, switch to some likely directory, then run the following command from a terminal window:

curl -s "https://chromium.googlesource.com/chromiumos/chromite/+/master/contrib/setup_adb?format=TEXT" | base64 --decode > chrome-adb.sh

This will download a bash script named chrome-adb.sh. Open it in your favorite text editor and confirm that you are comfortable with what it is doing. Or, Windows users might use the script as the basis for working out how to configure their SSH client and perform similar steps.

If you are comfortable with the script, ping your Chrome OS device (to confirm that you can reach it), then run the script:

ping <IP>
bash chrome-adb.sh <IP> <HOST>

Replace <IP> with the IP address of your Chrome OS machine that you determined previously. Replace <HOST> with the name that you want to use to identify this Chrome OS device in the future. This value only appears to be used inside of your SSH client configuration (~/.ssh/config) and is not used elsewhere.

If everything works, this should emit the following output, or something like it:

INFO: SSH connectivity established.
SELinux: Loaded file_contexts contexts from /file_contexts.
INFO: ADB set up complete.

Connect to Chrome OS for Development

When you want to develop using the Chrome OS device as the target, execute the following command:

adb connect <IP>:22

where <IP> is the same IP address that you used previously. Note that the official docs drop off the connect part, which does not work.

At this point, you should get the standard Android debugging authorization dialog, after which adb devices should show your connection, and you should be able to run apps on the Chrome OS device akin to how you do so for locally-connected devices, emulators, etc.

UPDATE 2016-07-19: If you used the instructions shown earlier in the previous section, adb access to your device may no longer work. If so, try turning off, then on, the Developer Options, via the switch in the action bar of the Developer Options screen. Then, try reconnecting via adb connect.


Need Android app development training for your team? Mark Murphy has trained hundreds! Learn more!