1.3 Debugging on a Hardware Device
While it is possible to debug most Wear features using the Android emulators, sometimes it is helpful to see the application on a real device. In this lesson I’ll show you how to debug your applications on a physical Wear device.
1.Introduction and Getting Set Up3 lessons, 11:45
2.Wearable App UI Components6 lessons, 1:15:54
3.Wearable Notifications4 lessons, 38:35
4.Creating a Watch Face2 lessons, 34:28
5.Conclusion1 lesson, 02:14
1.3 Debugging on a Hardware Device
Hey, everyone. This is Paul with Tuts+ and you're watching the Developing for Android Wear course. In the previous lesson we went ahead and set up our emulators so that we can do our development and to actually look at the applications as we make them. In this lesson I'm gonna walk you through how you would set up a physical Android Wear device that is hooked up to your phone so that it can work with a computer and you can install apps directly to it. So if you don't have a physical device or you would prefer to use just the emulator then that is fine. You can just go ahead and skip past this lesson. If you do have a physical device, I would really recommend using that for your development. I will be using the emulator throughout this course simply because it is available on the screen, but there are some bugs and I will mention them those when they do come up. So let's go ahead and get started. On your physical Android Wear device what you're going to want to do is click on the watch face. And you could scroll down to settings, and at the very bottom there should be an about section. So we're going to click on that and we're going to go down to the build number, and similar to the Nexus's devices, you can just click seven times, and this will set you into developer mode. So if we right swipe we'll go back to the setting screen. And you'll notice that developer options just came up. So we're going down to developer options, and we're gonna turn on ADB de-bugging, we'll hit the check mark, and we'll also turn on debugging over Bluetooth. So once that's enabled we can go ahead and scroll back. And you'll notice that we now have this card that says we are debugging over Bluetooth. Now this is only a half truth. You actually need to go on to your phone and go into the Android Wear companion app, and if you go into settings you'll notice that there is a screen here that you can go to, and there is an option at the bottom that's called debugging over Bluetooth. You will need to turn that on as well, and then when once that's set you can go into your terminal or command prompt, and wherever you can run your A D B commands. So I just happen to be in my platform tools folder. So we'll do .\adb devices. And we can see the emulator and my physical device. So what we're gonna do now is I'm just gonna go ahead and turn off the emulator. And we should just see my Nexus 6 there. So this is connected through USB to the computer. So there's actually a few commands here that we can run that will bridge our Android Wear device to our computer. So if we go ahead and type in ./abd forward tcp and then it's four 4's for the port. Localabstract:/adb-hub. And then secondly we want to use ./abd. connect localhost:4444. So that should connect through our phone. On your Android Wear device. If you've not connected your watch to your computer before, you will end up with a screen similar to this where you can hit OK or always allow from this computer. It's a similar screen to what you get with the dialogue on a phone when you first connect it to a computer for debugging. It's just giving permission to your device to work with that computer. So at this point, we should be able to type in ./adb devices, and you'll notice that we have a localhost 4444 device here now. So if we come back to Android Studio and we hit the Run button, we now see a physical Android Wear device in our selection of devices. So, in this case, it just happens to be a Moto360. I believe the Samsung You're Alive has a cradle with a USB plug with it. And that one doesn't need to be debugged over Bluetooth, you can just plug it in. So just something to be aware of. But for the most part you will be debugging over Bluetooth with physical devices. If you want to see the documentation for all of these steps, you can also look up debugging over Bluetooth on the Android documentation site and it will pretty much walk you through everything that we've just done. So, yeah, in the next lesson we are gonna go through Android Studio. And look at the hello world application that was generated for us and just kind of go through the different portions of the application and what we need to be aware of before we start developing. So I will see you then.