Preparing Your Development Environment for Android Wear - dummies

Preparing Your Development Environment for Android Wear

By Michael Burton

Because Android Wear is a companion to your phone rather than a completely standalone product, the development environment is familiar but slightly different from developing on regular Android.

Prepping your Android phone

Before you create the Android Wear emulator, you should prepare your phone.

Checking for system updates

Android Wear is an evolving platform, and it requires that certain services be up to date on your phone. Go to your phone’s Settings page, scroll down to About phone, and click System updates to make sure your phone has the latest software.

Installing Android Wear on your phone

Visit the Google Play Store and search for Android Wear. Install the app and then run it. You should see something like this:

The Android Wear welcome screen.

Setting up an Android Wear emulator

The next step is to create your Android Wear emulators. These are the devices on which you will develop your Wear apps.

  1. In Android Studio, choose Tools→Android→AVD Manager.

  2. Click Create Virtual Device.

  3. Choose Wear, select Android Wear Square, and click Next.

  4. Choose Lollipop API 21 x86, click Next, and then click Finished.

  5. Start the emulator by pressing the green right-pointing triangle Play button.

    Wait until the emulator initializes and shows the Android Wear home screen.

    Home screen on the Android Wear

  6. Repeat the Steps 1 to 4 but create an Android Wear Round emulator.

Pairing your phone with the Wear emulator

Now that your phone and emulator are ready to use Android Wear, you must pair them. Every Android Wear user pairs his watch to his phone, and the Android Wear app makes this easy. Because you are using an emulator rather than a physical device, you must go through a few extra steps to pair your devices:

  1. Connect the phone to your machine through USB.

  2. Forward the emulator’s communication port to the connected phone.

    You must do this every time the phone is connected:

    adb -d forward tcp:5601 tcp:5601

    The wearable emulator and your phone should now be listed when you run the adb devices command.

    $ adb devices
    List of devices attached 
    emulator-5554   device
    5b44a488839e3171       device
  3. Start the Android Wear app on your phone and connect to the ­emulator.

    You do this by choosing Pair with a new wearable and then choosing Pair with emulator from the overflow menu, as shown on the left and right images.

    The Android Wear app should report when your emulator is Connected.

    The Android Wear app should now report that your emulator is “Connected.” Your phone and emulator are now paired!

  4. Check that the pairing is working.

    You do this by tapping the menu on the top right corner of the Android Wear app, selecting Demo cards, then clicking a Demo card. As shown in the following figure, the card you select (left) appears as a notification(s) on the home screen (right). You can dismiss the card by swiping it off the screen to the right.

    Checking that the pairing is working.