Skip to content

Most visited

Recently visited

navigation

Creating and Running a Wearable App

This lesson describes how to start developing a wearable app, which runs directly on a watch. A wearable (watch) app can access low-level hardware such as sensors, activities, services, and more. Also see Standalone Apps.

To test your app with a companion (paired) phone, install the latest version of the Wear companion app on that phone.

Setting Up a Development Environment

To begin, install the latest version of Android Studio.

Use the SDK manager to install or confirm that you have the latest versions of the following:

Also see Update the IDE and SDK Tools.

Note: If you plan to make your Wear apps available for China, you must use the special release version 7.8.87 of the Google Play services client library to handle communication between a phone and watch. For information about configuring Wear apps for China, see Creating Android Wear Apps for China.

Creating or Updating a Project

Many features in Android Studio are available for developing your app. For an overview and links to more information, see Meet Android Studio.

Create a sample project

To create a sample project for development 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, optionally select the Phone and Tablet option. If you plan to use Android 7.1.1 APIs in a phone app, then the Minimum SDK option list, select API 25: Android 7.1.1 (Nougat).
  4. On the same Target Android Devices screen, select the Wear option, and in the Minimum SDK option list, select the latest available option, such as API 25: Android 7.1.1 (Nougat).
  5. Click Next until the Add an Activity to Wear screen is displayed.
  6. On the Add an Activity to Wear screen, select Blank Wear Activity and click Next.
  7. On the Customize the Activity screen, click Finish. Android Studio creates your project
  8. In the build.gradle file for the Wear module:
    • In the android section, confirm that the compileSdkVersion is set to 25.
    • In the android section, confirm that the targetSdkVersion is set to 25.
    • In the dependencies section, update (if necessary) the existing reference to the Wearable Support Library (for example, an existing reference could be compile 'com.google.android.support:wearable:1.4.0') by changing it to the following, which requires that your Google Repository is the latest version: compile 'com.google.android.support:wearable:2.0.0'

Update an existing project

To update an existing project for development:

  1. Start Android Studio, click Open an existing Android Studio Project, and select a project.
  2. If prompted by the Android SDK Manager for the SDK version to use for the project, select Use Android Studio's SDK.
  3. If prompted to update the Gradle plugin, update the version of the plugin.
  4. In the build.gradle file for the Wear module:
    • In the android section, update the compileSdkVersion to 25.
    • In the android section, update the targetSdkVersion to 25.
    • In the dependencies section, update the existing reference to the Wearable Support Library (for example, an existing reference could be compile 'com.google.android.support:wearable:1.4.0') by changing it to the following, which requires that the Google Repository is the latest version: compile 'com.google.android.support:wearable:2.0.0'

Setting Up a Watch or Emulator

We recommend that you develop on actual hardware to better determine the user experience. However, the watch emulator for Android Wear has benefits such as testing with different screen shapes.

Note: For detailed information about projects in Android Studio, see Projects Overview.

Set up a watch

After you enable adb debugging, you can use a watch during development.

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. A message appears on both the watch and the Android Wear app prompting you to allow debugging.

    Note: Also see information about debugging over Wi-Fi and Bluetooth.

  2. On the Android Wear app, tap Always allow from this computer and tap OK.

After you follow the instructions in Setting Up a Phone, you can run your app as follows:

  1. Open your app in Android Studio.
  2. Select your Wear app module name from the Run/Debug configuration drop-down menu (typically wear).
  3. Click the Play button.
  4. In the Select Deployment Target box, click your device.

After your app is installed on the watch, the app should run.

Set up an emulator

To use the Android Emulator, confirm that you have the latest version of the Android SDK Platform-tools from the SDK Manager.

Create and run a virtual device in Android Studio as follows:

  1. Open the AVD 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 a Nougat image to download. For example, select the image with the Release Name of Nougat, the API Level of 25, and the Target of "Android 7.1.1 (with Android Wear)". When the download and installation are complete, click Finish and then click Next.
  5. Verify the configuration of the Android Virtual Device (AVD) and click Finish. You may be prompted to accept necessary updates for the AVD.
  6. Start the emulator by clicking the Play button, selecting the new virtual device, and waiting until the emulator initializes and shows the Android Wear home screen.

Pair the phone with the emulator and sync a Google Account, as follows:

  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 handheld device (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.

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

Setting Up a Phone

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

Wear apps can 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 for use in development.

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.

Running an App

After you complete the steps to create a sample project and you have set up a watch or emulator, you can use the Play button in Android Studio (or use adb install) to run the "Hello World" sample activity in the wear module of the project you created.

Specifically, in your Android Studio project, select wear from the Run/Debug configuration drop-down menu and click the Play button. The activity will print "Hello world!"

Including Libraries

As part of the Project Wizard, the correct dependencies are imported for you in the appropriate module's build.gradle file. However, these dependencies are not required, so review the descriptions below to find out if you need them.

Notifications

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

Wearable Data Layer APIs

To sync and send data between watches and phones with the Wearable Data Layer APIs, you need the latest version of Google Play Services. If you are not using these APIs, remove the dependency from both modules.

Wearable support library

The wearable support library includes UI widgets; see Creating Custom Layouts. We recommend using the widgets because they exemplify best practices. The wearable support library is only for watch apps.

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

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

Hooray!

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.