Update: The build.gradle file had the wrong version of the package com.android.support:design. It’s now fixed and highlighted.
This guide is aimed for OS X users but the steps will be almost identical to the Windows users.

With Android O developer preview in the wild, it’s time to fire up the engines and start the process of migrating applications to the new version. Please bear in mind that the current version is a very early preview that is bound to change in the upcoming iterations. The final API’s will be announced in developer preview 3 between June and July, 2017. About a month later, Google Play store will start to accept Android O apps that can be run by users who opted in to the Android Beta program. With only a few months to get ready, let’s roll up the sleeves and get started!

Installing and configuring Android Studio 2.4 Canary with the Android O SDK

Android Studio 2.4 Canary is the bleeding-edge version of Android Studio with updates about once a week and it’s required for Android O development. Canary version can be installed simultaneously with the stable version so there’s no danger of breaking the existing installation. Download the preview version here (507 MB).

After installation, open the SDK manager from the Tools > Android menu.

Android Studio 2.4 Canary

Make sure that the SDK Platforms tab is open and tick the Show Package Details checkbox on the bottom-right corner of the window. On top of the list you should see an Android O Preview item. Select both Android SDK Platform O and Google APIs Intel x86 Atom System Image for installation as shown on the image on the right.

Android Studio SDK Manager - Android O
Make sure that the SDK Platforms tab is selected
Tick the “Show Package Details” checkbox to show the contents of each package
Select both “Android SDK Platform O” and “Google APIs Intel x86 Atom System Image”

Android Studio will ask you to accept the license agreement for the tools to be installed. Make sure to select both separately and click Accept on the lower part of the screen to enable the Next button.

Android SDK Manager License Agreement

The installer will both download and install the required components automatically. Make sure to have a few gigabytes of hard disk space to avoid problems with the installation.

Android SDK Manager Installation

Open the SDK Manager again and select the SDK Tools tab. Select the following items from the list:

  • Android SDK Build-Tools 26.0.0 rc1
  • Android SDK Platform-Tools 26.0.0 rc1
  • Android Emulator 26.0.0
  • Support Repository

Click OK to start the installation. This time there should be no license agreements to accept, installer starts to download the required components straight away.

Android O SDK Tools
Select the SDK Tools tab
Make sure to select Android SDK Build-Tools 26.0.0 rc1, Android SDK Platform-Tools 26.0.0 rc1, Android Emulator 26.0.0 and Support Repository.
Click OK to start the installation

After the tools have been installed, everything’s ready for Android O development. The easiest way is to use the recently installed emulator. Simply run the project and create a new Virtual Device with the Android O system image. For the developers that prefer real devices, the owners of the newer Nexus and Pixel phones are in luck. Google already provides system images for the following devices:

The image can be manually flashed to the device using the instructions provided by Google. Please note that flashing a system image removes all the data from the device!

Android Virtual Device - Android O System Image

The final step is to update build.gradle to point to the newly installed Android O preview. Take a look at an example file below. Important changes are bolded and colored green.

apply plugin: 'com.android.application' android { compileSdkVersion 'android-O' buildToolsVersion '26.0.0-rc1' defaultConfig { applicationId "com.hankidesign.testapplication" minSdkVersion 14 targetSdkVersion 'O' versionCode 1 versionName "1.0" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } } dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { exclude group: 'com.android.support', module: 'support-annotations' }) compile 'com.android.support:appcompat-v7:26.0.0-alpha1' testCompile 'junit:junit:4.12' compile 'com.android.support.constraint:constraint-layout:1.0.2' compile 'com.android.support:design:26.0.0-alpha1' }

Leave a Reply