Join David Gassner for an in-depth discussion in this video Connecting a physical watch with Bluetooth debugging, part of Building Apps for Android Wear Devices.
- There are some Android Wear watches, such as this Moto 360, that don't have a built in USB port. For these, you're going to need to set up Bluetooth debugging. Here's how you set it up on the watch. First go to the Settings. I'll swipe to the side to get to the app list and then touch Settings. If you don't see the Settings app, just scroll down till you find it. Then I'll scroll all the way down to the bottom to the About Setting.
I'll choose that. Then I'll scroll up until I get to Build number. Then I'll tap Build number seven times. This is just like on a phone or tablet. I'm turning on developer features. Now I'll scroll over and I see Developer options available. I'll select Developer options and then I'll turn on ADB debugging and I'll confirm. And then I'll select Debug over Bluetooth. So both ADB debugging and Debug over Bluetooth are enabled and I'm ready to go to the next step, configuring my phone as an ADB bridge over Bluetooth so I can connect to the watch.
The next step is to configure the phone so it can act as a bridge to the watch. This Nexus 6 is connected to my development computer with the USB cable and I've turned on USB debugging already. I've also paired the phone with the watch using the Android Wear application. The Moto 360 is Connected as shown in the upper-left corner. To turn on Bluetooth debugging from the watch, I'll touch the Gear icon in the upper-right corner and then down at the bottom, I'll turn on Debugging over Bluetooth.
Then I'll scroll a bit and I see Host disconnected and Target connected at the bottom. Now, I'll go back to my Command Prompt, and I'll type in some commands. The first command is adb forward then tcp:4444. Now that number could be anything at all as long as it's not a port number that's already in use on your computer. Then I'll type localabstract:/adb-hub.
You shouldn't see any response. Then I'll type adb connect localhost:4444. If you used a different number in the first command, use the same number in this command. If everything is successful, you should see connected to localhost:4444 and then on the phone, you should see Host connected and Target connected. You should now see this prompt on your watch asking if debugging is okay.
And I'm going to select Always allow from this computer. Then back on my development computer, I'll type adb devices and I see that the watch is attached. And if I go now into Android Studio to the Android window, I'll see the watch is listed there. Once you have Bluetooth debugging turned on, you can do everything with it that you can do with the watch that's connected with the USB cable. Loading apps for debugging and testing, debugging stepping through code, and issuing LogCat messages that you can see in your Android Studio LogCat window.
- Setting the SDK and devices for app development and testing
- Sending notifications to Android Wear devices
- Adding action buttons and voice input to notifications
- Stacking notifications
- Creating a new wearable app
- Managing layouts for different watch shapes
- Sending messages between phones and Android Wear devices
- Packaging an Android Wear app for distribution