Preparing Your Development Environment for Android Wear
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:
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.
In Android Studio, choose Tools→Android→AVD Manager.
Click Create Virtual Device.
Choose Wear, select Android Wear Square, and click Next.
Choose Lollipop API 21 x86, click Next, and then click Finished.
Start the emulator by pressing the green right-pointing triangle Play button.
Wait until the emulator initializes and shows the Android Wear home screen.
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:
Connect the phone to your machine through USB.
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
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 now report that your emulator is “Connected.” Your phone and emulator are now paired!
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.