1 page.title=Debugging over Bluetooth 2 page.tags=wear 3 helpoutsWidget=true 4 5 @jd:body 6 7 <div id="tb-wrapper"> 8 <div id="tb"> 9 10 <!-- Required platform, tools, add-ons, devices, knowledge, etc. --> 11 <h2>This lesson teaches you to</h2> 12 <ol> 13 <li><a href="#SetupDevices">Set Up Devices for Debugging</a></li> 14 <li><a href="#SetupSession">Set Up a Debugging Session</a></li> 15 <li><a href="#DebugApp">Debug Your App</a></li> 16 </ol> 17 <h2>You should also read</h2> 18 <ul> 19 <li><a href="{@docRoot}design/wear/index.html">Android Wear Design Principles</a></li> 20 </ul> 21 </div> 22 </div> 23 24 <p>You can debug your wearable over Bluetooth by routing its debug output to the 25 handheld device that's connected to your development machine.</p> 26 27 <h2 id="SetupDevices">Setup Devices for Debugging</h2> 28 <ol> 29 <li>Enable USB debugging on the handheld: 30 <ul> 31 <li>Open the Settings app and scroll to the bottom.</li> 32 <li>If it doesn't have a Developer Options setting, tap <b>About Phone</b> 33 (or <b>About Tablet</b>), scroll to the bottom, and tap the build number 7 times.</li> 34 <li>Go back and tap <b>Developer Options</b>.</li> 35 <li>Enable <b>USB debugging</b>.</li> 36 </ul> 37 </li> 38 <li>Enable Bluetooth debugging on the wearable: 39 <ol> 40 <li>Tap the home screen twice to bring up the Wear menu. </li> 41 <li>Scroll to the bottom and tap <b>Settings</b>.</li> 42 <li>Scroll to the bottom. If there's no <b>Developer Options</b> item, tap <b>About</b>, 43 and then tap the build number 7 times.</li> 44 <li>Tap the <b>Developer Options</b> item.</li> 45 <li>Enable <b>Debug over Bluetooth</b>.</li> 46 </ol> 47 </li> 48 </ol> 49 50 <h2 id="SetupSession">Set Up a Debugging Session</h2> 51 <ol> 52 <li>On the handheld, open the Android Wear companion app.</li> 53 <li>Tap the menu on the top right and select <b>Settings</b>.</li> 54 <li>Enable <b>Debugging over Bluetooth</b>. You should see a tiny status summary appear under the 55 option: 56 <pre> 57 Host: disconnected 58 Target: connected 59 </pre> 60 </li> 61 <li>Connect the handheld to your machine over USB and run: 62 <pre> 63 adb forward tcp:4444 localabstract:/adb-hub 64 adb connect localhost:4444 65 </pre> 66 67 <p class="note"><b>Note</b>: You can use any available port that you have access to.</p> 68 </li> 69 </ol> 70 <p> 71 In the Android Wear companion app, you should see the status change to:</p> 72 <pre> 73 Host: connected 74 Target: connected 75 </pre> 76 77 <h2 id="#debug">Debug Your App</h2> 78 79 Your wearable should show up as <code>localhost:4444</code> when running <code>adb devices</code>. 80 81 To run any <code>adb</code> command, use this format: 82 83 <pre>adb -s localhost:4444 <command> </pre> 84 85 <p>If there are no other devices connected over TCP/IP (namely emulators), you can shorten the command 86 to:</p> 87 <pre> 88 adb -e <command> 89 </pre> 90 <p>For example:</p> 91 <pre> 92 adb -e logcat 93 adb -e shell 94 adb -e bugreport 95 </pre> 96