原文 https://developer.android.com/training/wearables/apps/bt-debugging.html
This lesson teaches you to
You should also read
You can debug a watch app over Bluetooth by routing the app's debug output to the phone that is connected to your development machine.
Set Up Devices for Debugging
Enable USB debugging on the phone:
- In Settings > About phone, tap Build number seven times to enable the Developer Options.
- In Settings > Developer Options, enable USB debugging.
Enable Bluetooth debugging on the watch:
- Open the Settings menu on the watch.
- Scroll to the bottom of the menu and tap About.
- Tap the build number 7 times.
- From the Settings menu, tap Developer Options.
- Confirm that ADB debugging is enabled.
- Enable Debug over Bluetooth.
Set Up a Debugging Session
- On the phone, open the Android Wear companion app.
- Tap the Settings icon.
- Enable Debugging over Bluetooth. A status summary, as follows, is displayed under the option:
Host: disconnected Target: connected
- Connect the phone to your machine over USB and run:
adb forward tcp:4444 localabstract:/adb-hub adb connect 127.0.0.1:4444
Note: You can use any available port to which you have access.
- When prompted on the watch, confirm that you are allowing ADB Debugging.
In the Android Wear companion app, you should see the status change to:
Host: connected Target: connected
Debug Your App
Your watch is connected as 127.0.0.1:4444
when running adb devices
. To run any adb
command, use this format:
adb -s 127.0.0.1:4444 <command>
If there are no other devices connected over TCP/IP (namely emulators), you can shorten the command to:
adb -e <command>
For example:
adb -e logcat adb -e shell adb -e bugreport