ADB and testing Android apps

Being able to run Android apps on a Chromebook is great, it gives users access to the vast Android ecosystem offerings and it gives Android developers the opportunity to reach ChromeOS users.

Developers should make a point to verify their apps on different form factors, since this will help improve users’ experiences. This is why ChromeOS provides Android developers with the tools to deploy and test their apps on Chromebooks.

Whether developers are deploying their Android app directly from ChromeOS (using Android Studio in your Chromebook) or from another device, developers can use ADB⁠ to deploy their apps and debug different interactions with Chromebooks. For more details checkout the steps below.

Enable ADB debug

Previously, using ADB on your Chromebook was only possible while in developer mode, which requires powerwashing (resetting) the device and can reduce security. Luckily since Chrome 81, developers can keep their devices out of developer mode and still deploy apps they develop directly in ChromeOS, with the flip of a switch. Here is how:

First, make sure the Chromebook is not in developer mode⁠. Then go to settings and turn on Linux (if you haven’t done so before).

Once Linux is available open the Linux settings and you’ll find a new option ‘Develop Android apps’, open that option.

Toggle enable ADB debugging and the computer will restart.

When the computer restarts you’ll see a message that lets you know that there may be applications that were not downloaded from the app store on the device.

This device may contain apps that haven't been verified by Google

ADB is now available to deploy apps to your Chromebook, run debugging commands and interact directly with the device.

To ensure that your Android app works well on a variety of Chromebook devices and available form factors, Google recommends that you test your app on the following devices:

  • An ARM-based Chromebook
  • An x86-based Chromebook
  • A device with a touchscreen and one without one
  • A convertible device; that is, one that can change between a laptop and a tablet
  • A device with a stylus

Deploy from ChromeOS

After enabling ADB debugging, you can load an Android app directly onto your ChromeOS device using Android Studio or if you have an APK you can load it using the Terminal.

Deploy with Android Studio

After you have set up Android Studio⁠ and ADB as described above, you can push your apps to the Chromebook’s Android container directly from Android Studio.

The Chromebook will appear as an option in the device drop down:

Android Studio devices dropdown

Now you can push your app like any other Android device! The ADB authorization dialog appears the first time you try to push to a new device. After you authorize it, your application will launch in a new window.

That’s it, you can now deploy the app to the Chromebook, test and debug without the hassle of being in developer mode.

Deploy with Terminal

Install ADB if necessary:

sudo apt install adb

Connect to the device:

adb connect arc

An authorization popup for USB debugging appears the first time you try to deploy to the device, and you’ll need to allow it.

Authorization to connect to the device

Install your app from the terminal:

adb install [path to your APK]

Deploy from another device

If you can’t use the method described above and need to push your app from another device, you can connect the device to ADB using USB or a network address.

Connect to ADB over a network

  1. Make sure you enabled ADB debugging.

Get the IP address of your Chromebook:

  1. Click the clock in the bottom-right area of the screen.
  2. Click the gear icon.
  3. Click the network type you are connected to (Wi-Fi or Mobile data) then the name of the network.
  4. Take note of the IP Address.

Connect to your Chromebook:

  1. Return to your development machine and use ADB to connect to your Chromebook using its IP address:
    adb connect <ip_address>
  2. On your Chromebook, click Allow when prompted whether you want to allow the debugger. Your ADB session is established.

Troubleshooting ADB debugging over a network

Sometimes the ADB device shows that it’s offline when everything is connected properly. In this case, complete the following steps to troubleshoot the issue:

  1. Deactivate ADB debugging in Developer options.
  2. In a terminal window, run adb kill-server.
  3. Re-activate the ADB debugging option.
  4. In a terminal window, attempt to run adb connect.
  5. Click Allow when prompted whether you want to allow debugging. Your ADB session is established.

Connect to ADB over USB

To push your APK from another device into the Chromebook via USB, you must start your ChromeOS in developer mode⁠ so that you can configure the Chromebook and push apps from the host machine. This is the only method that currently requires Developer Mode, and it only works on a small number of devices⁠. Because of this, it’s recommended to use ADB over the network instead. If you’d still like to proceed, follow these steps to get into developer mode.

  1. Make sure you enabled ADB debugging.
  2. Determine if your device supports USB debugging⁠
  3. Press control+alt+t to start the ChromeOS terminal.
  4. Type shell to get to the bash command shell:
    crosh> shell
    chronos@localhost / $
  5. Type the following commands to set up your device:
    $ sudo crossystem dev_enable_udc=1
    $ sudo reboot

  6. After rebooting, open the terminal again and run the following command to enable ADB on the Chromebook’s USB port:
    $ sudo ectool usbpd <port number> dr_swap

Use this command each time you disconnect and reconnect a USB cable. To ensure your Chromebook is in UFP mode, you can run ectool usbpd <port number>.

  1. Plug in a USB cable to a supported port⁠ on your device
  2. Run adb devices from the Android SDK platform tools on your host machine to see your Chromebook listed as an ADB supported device
  3. On your Chromebook, click Allow when prompted whether you want to allow the debugger. Your ADB session is established.