Skip to content

Most visited

Recently visited

navigation

Creating and Running a Wearable App

Watch apps run directly on a watch. Your watch app can access low-level hardware such as sensors, activities, services, and more.

A companion phone app that contains the watch app is also required when you want to publish to the Google Play store. Watches don't support the Google Play store, so users download the companion phone app, which automatically pushes the watch app to the watch. The phone app is also useful for doing heavy processing, network actions, or other work and sending the results to the watch.

This lesson describes how to set up a device or emulator and create one project to contain your watch and phone app.

Update Your SDK

Before you begin building watch apps, you must:

To update your SDK with these components, see Get the latest 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 phone and watch. For information about configuring Wear apps for China, see Creating Android Wear Apps for China.

Set Up an Android Wear Emulator or Device

We recommend that you develop on real hardware so you can better gauge the user experience. However, the emulator lets you test different screen shapes, which is useful.

Set up an Android Wear Virtual Device

To set up an Android Wear virtual device:

  1. Click Tools > Android > AVD Manager.
  2. Click Create Virtual Device....
    1. Click Wear in the Category list:
    2. Select Android Wear Square or Android Wear Round.
    3. Click Next.
    4. Select a release name (for example, KitKat Wear).
    5. Click Next.
    6. (Optional) Change any preferences for your virtual device.
    7. Click Finish.
  3. Start the emulator:
    1. Select the virtual device you just created.
    2. Click the Play button.
    3. Wait until the emulator initializes and shows the Android Wear home screen.
  4. Pair your phone with the emulator:
    1. On your phone, install the Android Wear app from Google Play.
    2. Connect the phone to your machine through USB.
    3. Forward the AVD's communication port to the connected phone (you must do this every time the phone is connected):
      adb -d forward tcp:5601 tcp:5601
      
    4. Start the Android Wear app on your phone and connect to the emulator.
    5. Tap the menu on the top right corner of the Android Wear app and select Demo Cards.
    6. The cards you select appear as notifications on the home screen of the emulator.

Set Up an Android Wear Device

To set up an Android Wear device:

  1. Install the Android Wear app, available on Google Play, on your phone.
  2. Follow the app's instructions to pair your phone with your watch. This allows you to test out synced phone notifications, if you're building them.
  3. Leave the Android Wear app open on your phone.
  4. Enable adb debugging on the Android Wear device.
    1. Go to Settings > About.
    2. Tap Build number seven times.
    3. Swipe right to return to the Settings menu.
    4. Go to Developer options at the bottom of the screen.
    5. Tap ADB Debugging to enable adb.
  5. Connect the watch to your machine through USB, so you can install apps directly to it as you develop. A message appears on both the watch and the Android Wear app prompting you to allow debugging.

    Note: If you cannot connect your watch to your machine via USB, you can try connecting over Bluetooth.

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

The Android tool window on Android Studio shows the system log from the watch. The watch should also be listed when you run the adb devices command.

Create a Project

To begin development, create an app project that contains watch and phone app modules. In Android Studio, click File > New Project and follow the Project Wizard instructions, as described in Creating a Project. As you follow the wizard, enter the following information:

  1. In the Configure your Project window, enter a name for your app and a package name.
  2. In the Form Factors window:
    • Select Phone and Tablet and select API 9: Android 2.3 (Gingerbread) under Minimum SDK.
    • Select Wear and select API 20: Android 4.4 (KitKat Wear) under Minimum SDK.
  3. In the first Add an Activity window, add a blank activity for mobile.
  4. In the second Add an Activity window, add a blank activity for Wear.

When the wizard completes, Android Studio creates a new project with two modules, mobile and wear. You now have a project for both your phone and watch apps for which you can create activities, services, and custom layouts. The phone app does most of the heavy lifting, such as network communications, intensive processing, or tasks that require long amounts of user interaction. When the app completes these operations, your app should notify the watch of the results through notifications or by syncing and sending data to the watch.

Note: The wear module also contains a "Hello World" activity that uses classes from the wearable support library.

Install the Watch App

When developing, you install apps directly to the watch as with phone apps. Use either adb install or the Play button on Android Studio.

When you're ready to publish your app to users, you embed the watch app inside of the phone app. When a user installs the phone app from Google Play, a connected watch automatically receives the watch app.

Note: The automatic installation of watch apps does not work when you are signing apps with a debug key and only works with release keys. See Packaging Wearable Apps for complete information on how to properly package watch apps.

To install the "Hello World" app to the watch, select wear from the Run/Debug configuration drop-down menu and click the Play button. The activity shows up on the watch and prints "Hello world!"

Include the Correct 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 read the following descriptions to find out if you need them or not:

Notifications

The Android v4 support library (or v13, which includes v4) contains the APIs to extend your existing notifications on phones to support watches.

For notifications that appear only on the watch (meaning, they are issued by an app that runs on the watch), you can just use the standard framework APIs (API Level 20) on the watch and remove the support library dependency in the mobile module of your project.

Wearable Data Layer

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're not using these APIs, remove the dependency from both modules.

Wearable UI support library

This is an unofficial library that includes UI widgets designed for wearables. We encourage you to use them in your apps, because they exemplify best practices, but they can still change at any time. However, if the libraries are updated, your apps won't break since they are compiled into your app. To get new features from an updated library, you just need to statically link the new version and update your app accordingly. This library is only applicable if you create watch apps.

In the next lessons, you'll learn how to create layouts designed for watches, as well as how to use the various voice actions that are supported by the platform.

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.