Create incredible app experiences

Android

Build and test Android and Flutter apps on Chromebooks and securely debug your app on mobile via USB.

Android Studio

  1. For the stable release, download the latest version of Android Studio (1GB for 64-bit Linux).
  2. Copy the downloaded file to “Linux Files” using the Chrome OS Files app to access Android Studio in your Linux container.
  3. Unzip the file and delete it to save disk space:
tar -zxvf android-studio*.gz
rm android-studio*.gz

Note: alternatively, you can also use the easy .deb package from the Android Studio Preview page. Just download the .deb file, open in the files app, and chose install.

Run Android Studio:

android-studio/bin/studio.sh

Follow the prompts and wait as Android Studio downloads the essential components.

  1. Start a new Android Studio project.
  2. Select “Empty Activity.”
  3. Choose Kotlin or Java (and enable AndroidX if you’d like).
  4. Once the project is synched and built, exit Android Studio.

Now, add the platform-tools to the path:

gedit .bashrc

Scroll to the bottom and add the following (replace ~ with the correct directory if it’s not your home directory):

export PATH="$PATH:~/Android/Sdk/platform-tools"

Source the profile for this session (it should be automatically sourced on your next login):

source .bashrc

Set up adb to push apps straight to the Android container on device:

Note: Remember to first enable ADB debugging in developer options in your Chrome OS device's android preferences.

adb connect 100.115.92.2:5555

Open Android Studio again.

  1. Select Build → Run.
  2. Choose your device.
  3. Run!

For easy access after start-up, pin Android Studio to your launcher by right-clicking and choosing “Pin.”
Optional: If you’re doing a lot of Android development, you may want to connect adb to the local device every time you start Android Studio. One way to do this is to create your own script to attached adb and then start Android Studio.
Here’s how that looks:

gedit studio-adb.sh

Then, add:

#!/bin/sh

#Auto-connect adb to the local Android Container
~/Android/Sdk/platform-tools/adb connect 100.115.92.2:5555

#Start Android Studio
~/android-studio/bin/studio.sh

Save the file and exit. Then, make the script executable:

chmod a+x studio-adb.sh
./studio-adb.sh

IntelliJ IDEA

For IntelliJ IDEA, you can take your pick of the Community or Ultimate version.

  1. First, visit the JetBrains site.
  2. Choose “Download” and “Linux.”
  3. Download the tarball (tar.gz) file (~500MB).
  4. Copy the downloaded file to “Linux Files” using the Chrome OS Files app to access IntelliJ IDEA in your Linux container.
  5. Un-archive the tarball and then delete it to save disk space:
tar -zxvf idea*.gz
rm idea*.gz

You’ll see a directory named “idea-IC-183.5912.21.” You can leave it that way or rename it for easier navigation in the future:

mv idea-* intellij

Make sure you have a jdk installed, and then launch IntelliJ and follow the prompts:

sudo apt install -y default-jdk
intellij/bin/idea.sh

Flutter

Let’s set up a Flutter development environment using Android Studio.

  1. First, install Android Studio using the steps above.
  2. Build and run a basic, empty Android app to ensure everything is set up correctly.
  3. Next, download and install the latest version of Flutter (~250MB).
  4. Copy the downloaded file to “Linux Files” using the Chrome OS Files app to access Flutter from your Linux container.
  5. Unarchive the file and delete it to save disk space:
tar -xvf flutter*.xz
rm flutter*.xz

Now, you need to add the flutter binaries to the PATH. Check the current path and then open up the bash profile:

echo $PATH
gedit .bashrc

Scroll to the bottom and add the following (replace ~ with the correct directory if it’s not your home directory):

export PATH="$PATH:~/flutter/bin"

Source the profile for this session (it should be automatically sourced on your next login):

source .bashrc
echo $PATH

Let’s launch flutter doctor to see what’s left to set up:

flutter doctor

Install the necessary Flutter dependencies using Synaptic or the terminal:

sudo apt install -y lib32stdc++6

Accept the required licenses:

flutter doctor --android-licenses

Open up Android Studio.

  1. Go to File → Settings → Plugins.
  2. Click “Manage repositories.”
  3. Search for “Flutter” and install that plugin as well as the Dart dependency.
  4. Restart Android Studio.
  5. Go to File → Settings → Build, Execution, Deployment → Build Tools → Gradle → Android Studio.
  6. Check “Enable embedded Maven repository.”
  7. Follow the instructions at Flutter.dev for creating and testing a Flutter app.
  8. Run it!

Flutter (without Android Studio)

Let’s set up a Flutter development environment using the Android SDK and Visual Studio Code:

  1. First, download and install the latest version of Flutter.
  2. Copy the downloaded file to “Linux Files” using the Chrome OS Files app to access Flutter from your Linux container.
  3. Make sure you have xz utils installed:
sudo apt install -y xz-utils

Unarchive the file and delete it to save disk space:

tar -xvf flutter*.xz
rm flutter*.xz

Now, you need to add the flutter binaries to the PATH. Check the current path and then open up the bash profile:

echo $PATH
vim .bashrc

Scroll to the bottom and add the following (replace ~ with the correct directory if it’s not your home directory):

export PATH="$PATH:~/flutter/bin"

Source the profile for this session (it should be automatically sourced on your next login):

source .bashrc
echo $PATH

Launch flutter doctor to see what’s left to set up:

flutter doctor

Install the necessary Flutter dependencies using Synaptic or the terminal (we’ll accept the Android licenses later on):

sudo apt install -y lib32stdc++6

Install the necessary Android SDKs

First, install Java:

sudo apt update
sudo apt install -y default-jre
sudo apt install -y default-jdk

Next, download the Android SDK tools and select the “Command Line Tools only” option.

  1. Copy the downloaded file to “Linux Files” using the Chrome OS Files app to access it from your Linux container.
  2. Unzip the sdk-tools ($TOOLS_PATH will be this location going forward):
unzip sdk-tools-linux*

Add this path to your PATH:

export PATH="$PATH:$TOOLS_PATH/tools/bin"

Download the SDK packages using the sdkmanager:

sdkmanager "build-tools;28.0.3" "emulator" "tools" "platform-tools" "platforms;android-28" "extras;google;google_play_services" "extras;google;webdriver" "system-images;android-28;google_apis_playstore;x86_64"

Add the Android Platform Tools to your path (you should find this where you ran the sdkmanager command):

export PATH="$PATH:[/path/to/platform/tools]/platform-tools

Set the ANDROID_HOME variable to where you unzipped sdk-tools before (aka you’re $TOOLS_PATH):

export ANDROID_HOME="$TOOLS_PATH"

Now, run flutter doctor to accept the android-licenses:

flutter doctor --android-licenses

Flutter and Visual Studio Code

  1. First, download the 64-bit .deb file.
  2. Double-click on the .deb file from the Chrome OS Files app.
  3. Allow the installer to install the program.
  4. Visual Studio Code will now appear in your Chrome OS launcher.
  5. Open Visual Studio Code.
  6. Click on View → Command Palette.
  7. Type “install” and select Extensions: Install Extensions.
  8. Type “flutter” in the extensions search field, select Flutter in the list, and click “Install.”
    • This also installs the required Dart plugin.
  9. Go back to your command line and run flutter doctor again to make sure there is nothing missing!
flutter doctor

Flutter tips and tricks

Want to build your first app optimized for Chrome OS? Clone the flutter-samples repo and build our specific Chrome OS Hello-World example:

git clone https://github.com/flutter/samples
cd samples/chrome-os-hello-world
flutter run

Press the search key along with 1 through = to access F1–F12 on your Chrome OS keyboard.
For the current versions of Chrome OS, only certain ports from Crostini are exposed to the rest of the environments. Here’s an example of how to launch Flutter DevTools for an Android app with ports that will work:

flutter packages pub global run devtools -p 8000
cd path/to/your/app
flutter run --observatory-port=8080

Then, navigate to http://localhost:8000/?port=8080 in your Chrome browser.

Flutter Chrome OS Lint Analysis

The Flutter team has added Chrome OS specific Lint Analysis checks that are available to make sure that the app that your building is going to work well on Chrome OS. It looks for things like required hardware in your Android Manifest that aren’t available on Chrome OS devices, permissions that will imply unsupported hardware, as well as other properties or code that would bring a lesser experience on these devices.
To activate these, you have to update your analysis_options.yml file to include these options:

include: package:flutter/analysis_options_user.yaml
analyzer:
 optional-checks:
   chrome-os-manifest-checks

To run these from the command line:

flutter analyze

The analysis results will show in the Dart Analysis tab in your IDE (VSCode or Android Studio).

More resources

Optimizing Android apps for Chrome OS
Android Studio on Chrome OS
Why your app should be optimized for screens of all sizes