Skip to content

Most visited

Recently visited

navigation

Creating and Running a Wearable App

This page describes how to start developing an app for a watch. By running directly on a watch, a Wear app can access low-level hardware such as sensors, activities, services, and more.

A Wear app should work independently of a phone app, as this allows users the greatest flexibility in their choice of phones. For more information, see Standalone Apps.

Note: You can test your app on an actual watch by connecting to the watch via Wi-Fi or Bluetooth. Although the Android watch emulator allows for testing on devices with different screen shapes and sizes, development with an actual watch enables you to better evaluate the total user experience.

Setting Up Your Environment

Install the latest version of Android Studio. For information about creating apps in Android Studio, see Projects Overview.

Use the SDK manager to confirm that you have the latest version of the Android platform. Specifically, under the SDK Platforms tab, select Android 8.0 (Oreo).

If you plan to make your Wear apps available for China, see Creating Android Wear Apps for China.

Creating a Wear App

You can create a Wear app using Android Studio's New Project wizard.

Start a Wear project

To create a project in Android Studio:

  1. Click File > New > New Project.
  2. On the Configure your new project screen, accept the default values and click Next.
  3. On the Target Android Devices screen, select only the Wear option, and in the Minimum SDK list, select the latest available option.
  4. Click Next, and on the Add an Activity to Wear screen, select Blank Wear Activity and click Next.
  5. On the Customize the Activity screen, click Finish.

    Android Studio uses its templates to create an app.

  6. In the build.gradle file for the app module:
    • In the android section, confirm that the compileSdkVersion is set to 27.
    • In the android section, confirm that the targetSdkVersion is set to 27.
    • Update the dependencies section. The first dependency is for the Wear UI Library, which has classes that exemplify best practices. The second dependency is for the Wearable Support Library, which has additional classes (including for watch faces):
        dependencies {
          compile 'com.android.support:wear:27.0.0'
          compile 'com.google.android.support:wearable:2.1.0'
          provided 'com.google.android.wearable:wearable:2.1.0'
        }
  7. In the Android Manifest file (AndroidManifest.xml) of your app, indicate that your app is standalone. Specifically, add a meta-data tag as follows:
    • Find the <application> tag.
    • As a child of that tag, use a meta-data tag with a name of com.google.android.wearable.standalone and a value of true:
      <application>
      ...
        <meta-data
          android:name="com.google.android.wearable.standalone"
          android:value="true" />
      ...
      </application>
      
  8. Sync your Android Studio project.

Launch the emulator and run your Wear app

To use the emulator, you must configure an Android Virtual Device, referred to as an AVD. Confirm that you have the latest version of the Android SDK Platform-tools from the SDK Manager.

Configure an AVD and run your app as follows:

  1. In Android Studio, open the Android Virtual Device Manager by selecting Tools > Android > AVD Manager.
  2. Click Create Virtual Device.
  3. In the Category pane, select Wear and choose a hardware profile. Click Next.
  4. Select the O image to download. For example, select the image with the Release Name of O, the API Level of 27, and the Target of "Android 8.0 (Android Wear)". Click Next and then click Finish.
  5. Close the Android Virtual Device Manager.
  6. In Android Studio, click the Run button.
  7. Select the new AVD, and click OK.

    The AVD starts and, after a few moments, runs your app. A "Hello..." message is displayed.

For more information about using AVDs, see Run Apps on the Android Emulator.

Pair a phone with the watch AVD

If you want a Google Account on the watch AVD for development, you can pair a phone with the watch AVD and sync a Google Account:

  1. Follow the steps for setting up a phone.
  2. On the phone, enable Developer Options and USB Debugging.
  3. Connect the phone to your computer through USB.
  4. Forward the AVD's communication port to the connected phone (each time the phone is connected):
    adb -d forward tcp:5601 tcp:5601
  5. On the phone, in the Android Wear app, begin the standard pairing process. For example, on the Welcome screen, tap the Set It Up button. Alternatively, if an existing watch already is paired, in the upper-left drop-down, tap Add a New Watch.
  6. On the phone, in the Android Wear app, tap the Overflow button, and then tap Pair with Emulator.
  7. Tap the Settings icon.
  8. Under Device Settings, tap Emulator.
  9. Tap Accounts and select a Google Account, and follow the steps in the wizard to sync the account with the emulator. If necessary, type the screen-lock device password, and Google Account password, to start the account sync.

Updating an Existing Project

If you have an existing project, you may need to update your build.gradle file. Version 4.1 of Gradle supports the use of google() for indicating the Google Maven repository; prior versions of Gradle do not. For related information, see Google's Maven repository.

Thus, if your Gradle version is lower than 4.1, provide the Google Maven repository URL in the build.gradle file for your Android Studio project. Specifically, in the repositories section, add a maven section as follows:

  allprojects {
      repositories {
          jcenter()
          maven {
              url "https://maven.google.com"
          }
      }
  }

Setting Up a Watch

Deploying an app to a watch is similar to deploying an app to a phone.

This section assumes that your watch has a USB port. If your watch lacks a USB port, see the instructions for connecting your watch via Wi-Fi or Bluetooth.

Enable adb debugging on the watch:

  1. Open the Settings menu on the watch.
  2. Scroll to the bottom of the menu. If no Developer Options item is provided, tap System and then About.
  3. Tap the build number 7 times.
  4. From the Settings menu, tap Developer Options.
  5. Enable ADB debugging.

Connect the watch:

  1. Connect the watch to your machine through USB, so you can install apps directly to the watch. Alternatively, connect the watch to your machine over Wi-Fi or Bluetooth.
  2. On the watch, tap Always allow from this computer and tap OK.

After you connect the watch, run your app by selecting a deployment target as you would with a phone.

Setting Up a Phone

This section contains information about setting up a companion phone with an Android Wear companion app.

Note: Wear apps should be standalone, and work independently of a phone. However, if your app depends on a phone app, see the information below about updating a phone with the latest Android Wear companion app.

Using the Android version of the companion app

On an Android phone, go to the Android Wear app listing. Tap Update to download and install the app. After installation, confirm that Auto-update is selected for the app (see the "Set up automatic updates for specific apps" section of Update downloaded apps). Tap Open to start the app.

Pair an Android phone to a watch

After you install the companion app on a phone, unpair ("Forget") any obsolete watch pairings, if necessary. Then you can pair the phone to a newly-imaged watch:

  1. On the phone, select your device name from the list of devices. A pairing code is displayed on the phone and on the watch. Ensure that the codes match.
  2. Tap Pair to continue the pairing process. When the watch is connected to the phone, a confirmation message is displayed. On the phone, a screen is displayed that lists the accounts on the phone.
  3. Choose a Google Account to add and sync to your watch.
  4. Confirm the screen lock and enter the password to start the copying of the account from the phone to the watch.
  5. Follow the instructions in the wizard to finish the pairing process.

Companion app for iPhones

An iOS companion app is available but the phone on which the app is installed must be running iOS 8.2 or higher:

  1. On your iPhone, visit the App Store and download the Android Wear app. Install the app on your iPhone.
  2. Follow the instructions on the watch and on the phone to begin the pairing process. For additional information, see the related Help page.

Including Libraries

When you use Android Studio's Project Wizard, the wizard imports dependencies in the appropriate module's build.gradle file. However, the dependencies are not required for all apps; please review the information below about the dependencies.

To update an existing Wear project to the latest SDK version, use the settings listed in the Start a Wear project section.

Notifications

For information about dependencies for notifications, see Creating a Notification for Wearables.

Wear UI Library

The components in the Wear UI Library are recommended because they exemplify best practices for watch apps. Therefore, it is recommended that you add a dependency on the Android Support Library. For more information, see the following pages:

Wearable Support Library

The Wearable Support Library has UI components for watch apps. Some of its classes are deprecated. For information about the classes that replace the deprecated ones, see Using the Wear UI Library.

Although the UI components can change at any time, a change in a component doesn't cause an app to break (because the components are compiled into your app). To get new features from an updated library, statically link the new library version and update your app accordingly.

Play Services and the Wearable Data Layer APIs

If your app depends on Google Play Services, either to sync and send data (using the Data Layer APIs) or for other reasons, you need the latest version of Google Play Services. If you are not using these APIs, remove the dependency.

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!

Follow Google Developers on WeChat

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 short survey?
Help us improve the Android developer experience.
(Sep 2017 survey)