A couple of weeks ago I bought a Google Pixelbook. I’ve been doing a bit of Android Development on it, mostly to optimize Pigment for Chromebooks. It’s taken some experimentation and discovery to find out how to get things set up, largely because the Android documentation is slightly out of date, so I thought I would share my experience, hopefully saving others time.

This post serves as a step by step guide to getting up and running with Android Studio on a Pixelbook (and, hopefully, other Chromebooks as well). I plan to write a full review once I’ve had some more time to kick the tires.

Developer Mode

In order to debug Android apps on your Pixelbook you’ll need to put the device in developer mode. You can do this on a Pixelbook by simply holding down Escape and Refresh while you press the power button. Once in Recovery mode, press Ctrl-D and confirm at the prompt to wipe the device and put it in developer mode. Now, every time you boot the device you’ll have to press Ctrl-D.

Enable Linux Apps

Once the device boots into Developer mode, you can turn on support for Linux apps (like Android Studio) by clicking on the clock, then the settings icon, and flipping the switch for Linux Apps on. This will take a little time to install the Terminal, but once it’s finished you’ll have a semi-complete linux environment.

Installing Android Studio

Next up you’ll need to install some support libraries for Android Studio, which you can easily do in the terminal. This includes installing OpenJDK, which is required to run Gradle builds from the command line.

sudo apt install libc6-i386 zlib1g lib32z1 openjdk-8-jdk-headless

Now head on over to the Android Studio download page to download the Linux version of Android Studio. Once the download completes you can simply drag it from the Downloads directory to the Linux Files item in the sidebar of the Files app. This will copy Android Studio to your linux home directory.

Next up you just need to unzip Android Studio, move it to an appropriate location, and start it up.

unzip android-studio-ide-*-linux.zip
sudo mv android-studio /opt/
rm android-studio-ide-*-linux.zip
/opt/android-studio/bin/studio.sh &

Now you should see Android Studio start to boot up, and you can go through the standard setup flow, until you get to the project picker screen. At this point you have a fully working installation of Android Studio, but you’ll find the performance lacking at this point, so there are still a few tweaks to make.

Enable ADB Debugging on Pixelbook

To build and run apps on your Pixelbook you’ll need to enable ADB debugging, just like any Android device. To do this, you need to open the Android Settings app, and tap that build number, just like always.

The only way I’ve found to get to the Android settings is through the standard settings, Google Play settings, then tap Manage Android Preferences. From there it’s standard Android settings.

Tweak Android Studio

Create a Launcher Icon

At this point you can launch Android Studio from the command line, but that’s not ideal. In the Configure menu of the project picker you can select Create Desktop Launcher to add an Android Studio icon to the ChromeOS app launcher.

Increase the Memory

It’s well known that Android Studio requires a lot of memory, so the first step is to increase the max memory size. My Pixelbook has 8Gb of memory, so I’m testing out Android Studio with 2Gb of max memory. I’ll probably test higher, but this seems to be okay for now.

To set the max memory allocation, from the help menu, select Edit Custom VM Options. This will open the vm options file used by Android Studio in a standard editor window. Add (or update) this line to set the max memory to 2Gb.

-Xmx2g

Once you save that, restart Android Studio and you should see some performance increases.

Install your SDKs and Support Packages

You can use the standard Android Studio SDK manager to install the required SDKs and supporting material (like NDK, Constraint Layout, Play Services, etc.).

Setup Your Environment

To easily build from the command line, there are some things to add to your environment. You can do this by editing your ~/.bashrc to add the following:

The Linux environment doesn't seem to come with a simple text editor, but you can install whichever you prefer via apt. I usually use Nano for simple edits.
export ANDROID_HOME=~/Android/Sdk

# Uncomment this if you installed the NDK from the Sdk Manager
#export ANDROID_NDK_HOME=$ANDROID_HOME/ndk-bundle

export PATH=$PATH:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools

function connect_adb() {
	adb connect 100.115.92.2:5555
}

That last one is a convenience I use since I can never remember the IP address to connect the Pixelbook to ADB. This lets you simply type connect_adb, complete with tab completion, to connect the Pixelbook for debugging.

Optimize Gradle

Lastly, you’ll need to update some configuration of gradle to make builds performant. To do this, you’ll need to create a file at ~/.gradle/gradle.properties, creating the .gradle directory if it doesn’t already exist. Add the following to that file.

org.gradle.jvmargs=-Xmx2g
org.gradle.daemon=true
org.gradle.caching=true

This sets the max memory for the Gradle JVM to 2Gb and enables the daemon and caching. Again, the memory number here will need some tweaking based on your projects and device, but this seems to be a good starting point.

Conclusion

Following these steps, I’ve found the Pixelbook to be mostly manageable for development. Linux apps, and Android Studio, on ChromeOS are still new, so there are some things that still need to be worked out. One example I’ve run into is running out of memory and needing to restart the device each evening, or so. Fortunately, ChromeOS boots extremely fast, so it’s not a big issue, and I’m hopeful that these issues will be ironed out in the months to come.