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