Skip to content

Most visited

Recently visited

navigation

Optimizing Apps for Chromebooks

Google Chromebooks now support the Google Play Store and Android apps. This document describes some ways that you can optimize your Android apps for Chromebooks.

Update Your App's Manifest File

To begin optimizing your Android app for Chromebooks, update your manifest file (AndroidManifest.xml) to account for some key hardware and software differences between Chromebooks and other devices running Android.

As of Chrome OS version M53, all Android apps that don't explicitly require the android.hardware.touchscreen feature will also work on Chrome OS devices that support the android.hardware.faketouch feature. However, if you want your app to work on all Chromebooks in the best possible way, go to your manifest file and adjust the settings so that the android.hardware.touchscreen feature is not required, as shown in the following example. You should also review your mouse and keyboard interactions.

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
          ... >
    <!-- Some Chromebooks don't support touch. Although not essential,
         it's a good idea to explicitly include this declaration. -->
    <uses-feature android:name="android.hardware.touchscreen"
                  android:required="false" />
</manifest>

Different devices often have different sensors available in them. See the Sensors Overview document for an overview of all sensors that the Android platform supports. Although Android handheld devices may have GPS and accelerometers, sensors are not guaranteed to be available in every Chromebook. However, there are cases where the functionality of a sensor is provided in another way. For example, Chromebooks may not have GPS sensors, but they still provide location data based on Wi-Fi connections. If you want your app to run on Chromebooks, regardless of sensor support, you should update your manifest file so that none of the sensors are required.

Note: If you don't require a particular sensor for your app but still use measurements from the sensor when it's available, make sure you dynamically check for the sensor's availability before trying to gather information from it in your app.

Some software features are unsupported on Chromebooks. For example, apps that provide custom IMEs, app widgets, live wallpapers, and app launchers aren't supported and won't be available for installation on Chromebooks. For a complete list of software features that aren't currently supported on Chromebooks, see incompatible software features.

Leverage Support for Multi-Window Mode

The implementation of Android apps on Chrome OS includes basic multi-window support. Instead of automatically drawing over the full screen, Android renders apps on Chrome OS into layouts that are appropriate for this form factor.

For more information, see Window management.

Support the Keyboard, Trackpad, Mouse, and Stylus

All Chromebooks have a physical keyboard and a trackpad, and some Chromebooks have a touchscreen as well. Some devices can even convert from a laptop to a tablet.

Many existing apps already support mouse and trackpad interactions with no extra work required. However, it's always best to adjust your app's behavior appropriately when users interact with it using a trackpad instead of a touchscreen, and you should support and distinguish between both interfaces properly. Given the support for physical keyboards, you can now provide hotkeys to enable your app's users to be more productive. For example, if your app supports printing, you can use Control+P to open a print dialog.

Check for Networking Requirements

Chromebooks run the entire Android OS in a container, similar to Docker or LXC. This means that Android will not have direct access to the system's LAN interface. Instead, IPv4 traffic will pass through an internal layer of network address translation (NAT), and IPv6 unicast traffic will be routed through an extra hop. Outbound unicast connections from an Android app to the internet should mostly work as-is; but in general, inbound connections are blocked. Multicast or broadcast packets from Android will not be forwarded to the LAN through the firewall.

As a special exception to the multicast restriction, Chrome OS runs a service that forwards mDNS traffic between Android and the LAN interface, so the standard Network Service Discovery APIs are the recommended way to discover other devices on the LAN segment. After finding a device on the LAN, an Android app can use standard TCP or UDP unicast sockets to communicate with it.

IPv4 connections originating from Android will use the Chrome OS host's IPv4 address. Internally, the Android app will see a private IPv4 address assigned to the network interface. IPv6 connections originating from Android will use a different address from the Chrome OS host, as the Android container will have a dedicated public IPv6 address.

Use Backup and Restore Effectively

One of the strongest features of Chromebooks is that users can easily migrate from one device to another. That is, if someone stops using one Chromebook and starts using another, they simply have to sign in, and all of their apps appear.

Tip: Although it's not mandatory, backing up your app's data to the cloud is a good idea.

Chromebooks can also be shared among a large number of people, such as in schools. Since local storage is not infinite, entire accounts—together with their storage—can be removed from the device at any point. For educational settings, it's a good idea to keep this scenario in mind.

Update the NDK Libraries

If your app uses the Android NDK libraries, and its target SDK version is 23 or higher, ensure that text relocations are removed from both the ARM and x86 versions of your NDK libraries, as they're not compatible in Android 6.0 (API level 23) and higher. By leaving text relocations in your NDK libraries, you may also cause incompatibility errors with Chromebooks, especially when running on a device that uses an x86 architecture.

Note: To view more details on updating NDK libraries properly, see the Runtime section of the Android 6.0 Changes document.

Update to Android 7.0 (API level 24)

Android apps on Chromebooks now ship with APIs for Android 6.0 (API level 23) and Android 7.0 (API level 24). By following the best practices outlined above, your app takes advantage of all the improvements in the Android platform. For example, multi-window support is better integrated, and you're able to resize activities arbitrarily, making them feel more natural. You can also access APIs for drag-and-drop operations across apps and mouse cursor control.

Resolve Issues with Screen Size

To ensure that your native apps are able to display their entire contents to the user, read the recommended guidelines and things to watch out for. See Screen Size Compatibility for Chromebooks.

Resolve Issues with Camera Preview Images

Camera problems can arise when the app can only run in portrait orientation but the user runs it on a landscape screen. In this case, the preview —or the captured result—could be incorrectly rotated.

To avoid all camera issues, you must do the following:

If you do the above, the compatibility mode takes care orienting the screen correctly.

Test Your App

To load your app onto your Chromebook for testing, you must enter Developer mode on your Chrome OS device and enable unknown sources. See the Putting your Chrome OS Device into Developer Mode document for detailed instructions about moving your device into Developer mode. After your device is in Developer mode, you can go to your Chrome settings and select Enable Unknown Sources under the security in app settings.

After enabling Developer mode, you can load an Android app onto your Chrome OS device using one of several methods. For more details, see the Load Your App section of the Loading Apps on Chromebooks page.

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:

To view the full list of supported devices, see the Chrome OS Device Support for Apps page.

Set Up ADB

Before attempting to set up an ADB connection, you must start your Chrome OS in Developer Mode so that you have the ability to install Android apps on the Chromebook.

Caution: After switching your Chrome OS device to Developer mode, it restarts and clears all existing data on the device.

To set up ADB, complete the following steps:

  1. Press Control+D to start your device.
  2. Finish the setup process.
  3. Log into your test account.
  4. Accept the Google Play Store terms and service conditions.

Configure the firewall

To configure the Chrome OS firewall to allow incoming ADB connections, complete the following steps:

  1. Press Control+Alt+T to start the Chrome OS terminal.
  2. Type shell to get to the bash command shell:
    crosh> shell
    chronos@localhost / $
    
  3. Type the following commands to set up developer features and enable disk-write access for the firewall settings changes:
    chronos@localhost / $ sudo crossystem dev_boot_signed_only=0
    chronos@localhost / $ sudo /usr/libexec/debugd/helpers/dev_features_rootfs_verification
    chronos@localhost / $ sudo reboot
    
    The sudo reboot command restarts your Chromebook.

    Note: You can press the Tab key to enable autocompletion of file names.

    Note: You must complete this procedure only once on your Chromebook.

  4. After your device restarts, log in to your test account and type the following command to enable the secure shell and configure the firewall properly:
    chronos@localhost / $ sudo /usr/libexec/debugd/helpers/dev_features_ssh
    
    You can now exit out of the shell.

Check the IP address of your Chromebook

To verify the IP address of your Chromebook, complete the following steps:

  1. Click the clock icon in the bottom-right area of the screen.
  2. Click Settings.
  3. The Internet Connection section in the Settings area lists all of the available networks. Select the one that you want to use for ADB.
  4. Take note of the IP address that appears.

Enable ADB debugging

To enable ADB debugging, complete the following steps:

  1. Click the clock icon in the bottom-right area of the screen.
  2. Click Settings.
  3. In the Android Apps section, click the Settings link in the line that reads Manage your Android apps in Settings. This brings up the Android apps settings.
  4. Click About device.
  5. Click Build number seven times to move into Developer mode.
  6. Click the arrow in the top-left area of the window to go back to the main Settings screen.
  7. Click the new Developer options item, activate ADB debugging, and then click OK to allow ADB debugging.
  8. Return to your development machine and use ADB to connect to your Chromebook's using its IP address and port 22.
  9. On your Chromebook, click Allow when prompted whether you want to allow the debugger. Your ADB session is established.

Troubleshooting ADB debugging

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.

Enabling Android developer options

To get to the developer settings, do the following:

  • Go to the Chrome OS settings
  • Type "Android" into the search bar
  • Click on the link to "Android settings"
  • .
  • From the Android Settings app, you can activate the developer mode as normal.

Tip:You might want to right click on the settings icon in the shelf and pin it there to get faster access in the future.

The Android developer options include the following additions for Chrome OS:

  • If you turn on the resizing option, you can freely resize your window to see that your app properly handles window size changes. Make sure that the resizing is fast and fluid.
  • If you turn on the debug information, the caption shows you the window manager's state for the window that defines its capabilities.

Develop test cases for your app

First, make sure that the proper manifest flags are specified. These flags include the desired orientation, where setting screenOrientation to unspecified is best. If you specify an orientation like landscape, consider sensorLandscape to make sure that the experience on a tablet is optimal. If you have special size or orientation requests you should also consider adding the new meta tags as size or orientation hints—which only affects desktop environments. If you want to change it also on phones, you should specify layout android:defaultHeight, android:defaultWidth, or android:minHeight instead.

If you are interested in specific input device handling for specific device categories, you should specify android.hardware.type.pc to disable the input compatibility mode.

Test window resizing by pressing the full screen key (F4), maximizing, and restoring. Even better is to enable free resizing via developer options and see that your app is smoothly resizing and not crashing.

Try to change from laptop into tablet mode to see that everything works as expected. Rotate the device to see that everything is ok. Transition back into laptop mode. Repeat this step a few times.

Make sure that the window bar is not breaking your app by offsetting UI elements or location-based input. If it does, please look at the view hierarchy and make sure that your app does not add view elements inside the system area.

If you are using the camera or other hardware features—like the pen—make sure that it behaves properly when performing the window and device changes as outlined above.

Even though this is a standard procedure on Android, using multiple windows can uncover problems much easier. As such you should use onSaveInstanceState to save and restore your state as well as possible. To test this you should minimize your app for some time, start something else which uses a lot of memory and then restore your app to see if it restores the previous state.

If you are using any kind of networking, make sure that the app is able to restore the data signal after a connection problem or device resume.

Additional Learning Materials

To learn more about optimizing your Android apps for Chromebooks, consult the following resources:

This site uses cookies to store your preferences for site-specific language and display options.

Get the latest Android developer news and tips that will help you find success on Google Play.

* Required Fields

Hooray!

Browse this site in ?

You requested a page in , but your language preference for this site is .

Would you like to change your language preference and browse this site in ? If you want to change your language preference later, use the language menu at the bottom of each page.

This class requires API level or higher

This doc is hidden because your selected API level for the documentation is . You can change the documentation API level with the selector above the left navigation.

For more information about specifying the API level your app requires, read Supporting Different Platform Versions.

Take a one-minute survey?
Help us improve Android tools and documentation.