Skip to content

Most visited

Recently visited


Migrating Apps to Android O

Android O introduces several new features and APIs, and includes changes that can affect the behavior of your app even if you change nothing. To help you prepare, this page explains how to perform compatibility testing and how to update your app to use new Android O features:

  1. Ensure platform compatibility

    Verify that your app is fully functional on the new version of the platform. At this stage, you do not use new APIs or change your app's targetSdkVersion, but minor changes might be necessary.

  2. Build your app with the Android O SDK

    When you are ready to take advantage of the new features of the platform, update your targetSdkVersion to "O", verify the app continues to function as expected, and then begin using new APIs.

Ensure platform compatibility

The objective here is to make sure that your app works as-is on Android O. Because some platform changes might affect the way your app behaves, some adjustments might be necessary, but you do not need to use new APIs or change your targetSdkVersion.

Prepare a device running Android O

Perform compatibility testing

For the most part, testing compatibility with Android O entails the same type of testing you perform when preparing to release your app. This is a good time to review the Core App Quality Guidelines and Best Practices for Testing.

However, there's another aspect to testing: Android O introduces changes to the Android platform that can affect your app's behavior or break the app altogether, even if you do not change your targetSdkVersion. For this reason, it is important that you review the key changes in table 1, and test any fixes that you implement to accommodate the changes.

Table 1. Key changes that affect all apps running on Android O devices.

Change Summary Further reference
Less frequent background location updates If your app receives location updates from a background service, it receives less frequent updates on Android O compared to older versions of Android. Specifically, a background service cannot receive location updates more than a few times per hour. However, while your app is in the foreground, the rate of location updates is unchanged. Background Location Limits
net.hostname no longer supported Querying the net.hostname system property produces a null result. None
New exception from send(DatagramPacket) The send(DatagramPacket) method throws a SocketException if the previously executed connect(InetAddress, int) method failed. Behavior Changes: Network and HTTP(S) connectivity
Proper NullPointerException from AbstractCollection methods AbstractCollection.removeAll(null) and AbstractCollection.retainAll(null) now always throw a NullPointerException; previously, the NullPointerException was not thrown when the collection was empty. This change makes the behavior consistent with the documentation. Behavior Changes: Collection handling
Proper NullPointerException from Currency.getDisplayName(null) Calling Currency.getDisplayName(null) throws a NullPointerException. Behavior Changes: Locales and internationalization

For a more extensive list of behavior changes in Android O, also see Android O Behavior Changes.

Build your app with Android O features

In addition to offering you new APIs, Android O causes other behavior changes when you update your targetSdkVersion, as described in table 2. This section explains how to setup your development environment to target the new platform and begin building and testing the changes and new features with Android O APIs.

Note: The steps described above to ensure platform compatibility are prerequisite to building for Android O, so be sure you complete those steps first.

Get the Android O SDK

  1. Install Android Studio 3.0 Canary.

    Only Android Studio 3.0 includes support for all the new developer features available with Android O. So you need to get the canary version of Android Studio 3.0 to begin using the Android O SDK. But you can still keep your stable version of Android Studio installed.

  2. Launch Android Studio 3.0 and open the SDK Manager by clicking Tools > Android > SDK Manager.
  3. In the SDK Platforms tab, check Show Package Details. Below Android O Preview check the following:
    • Android SDK Platform O
    • Google APIs Intel x86 Atom System Image (only required for the emulator)
  4. Switch to the SDK Tools tab and check all items that have updates available (click each checkbox that shows a dash ). This should include the following that are required:
    • Android SDK Build-Tools 26.0.0 (rc2 or higher)
    • Android SDK Platform-Tools 26.0.0 (rc2 or higher)
    • Android Emulator 26.0.0
  5. Click OK to install all the selected SDK packages.

Now you're ready to starting developing with the Android O Developer Preview.

Update your build configuration

Update compileSdkVersion, buildToolsVersion, targetSdkVersion, and the Support Library version with the following versions:

android {
  compileSdkVersion 'android-O'
  buildToolsVersion '26.0.0-rc2'

  defaultConfig {
    targetSdkVersion 'O'

dependencies {
  compile ''

// REQUIRED: Google's new Maven repo is required for the latest
// support library that is compatible with Android O
repositories {
    maven {
        url ''

You cannot publish your app with this configuration. The "O" version is a provisional API level that is usable only for development and testing during the Android O Developer Preview. You must wait to publish your Android O changes until the final API level is released, and then update your configuration again at that time.

Remove broadcast receivers from your manifest file

Because Android O introduces new limitations for broadcast receivers, you should remove any broadcast receivers that are registered for implicit broadcast intents. Leaving them in place does not break your app at build-time or runtime, but they have no effect when your app runs on Android O.

Explicit broadcast intents—those that only your app can respond to—continue to work the same on Android O.

There are exceptions to this new restriction. For a list of implicit broadcasts that still work in apps targeting Android O, see Implicit Broadcast Exceptions.

Test your Android O app

With the above preparations complete, you can build your app and then test it further to make sure it works properly when targeting Android O. This is another good time to review the Core App Quality Guidelines and Best Practices for Testing.

When you build your app with the targetSdkVersion set for Android O, there are specific platform changes you should be aware of. Some of these changes can significantly affect your app's behavior or even break your app altogether, even if you do not implement new features in Android O.

Table 2 provides a list of these changes with links to more information.

Table 2. Key changes that affect apps when targetSdkVersion is set to "O".

Change Summary Further reference
Privacy Android O does not support use of the net.dns1, net.dns2, net.dns3, or net.dns4 system properities. Behavior Changes: Privacy
Writable and Executable Segments Enforced For native libraries, Android O enforces the rule that data shouldn’t be executable, and code shouldn’t be writable. Behavior Changes: Native Libraries
ELF header and section validation The dynamic linker checks more values in the ELF header and section headers, and fails if they are invalid. Behavior Changes: Native Libraries
Notifications Apps targeting Android O version of the SDK must implement one or more notification channels to post notifications to users. API Overview: Notifications
The List.sort() method Implementations of this method may no longer call Collections.sort(), or your app will throw an exception due to stack overflow. Behavior Changes: Collection handling
The Collections.sort() method In List implementations, Collections.sort() now throws a ConcurrentModificationException. Behavior Changes: Collection handling

For a more extensive list of behavior changes in Android O, see Android O Behavior Changes.

To explore the new features and APIs available with Android O, see Android O Features and APIs.

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


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.