Translate

Monday, October 30, 2017

Android Wear Watch adb Debugging over Bluetooth


Debugging over Bluetooth


Bluetooth debugging only works for Android-paired watches. Before you begin, be sure the watch and phone are paired and you've enabled developer options on the watch. You should also be sure that developer options is also enabled on the phone. To check, open the phone's Settings menu, select About phone and click the build number seven times.

Enable USB debugging on the phone

  1. Open the phone's Settings menu.
  2. Select Developer Options and enable USB debugging.

Enable ADB/Bluetooth debugging on the watch

  1. Open the watch's Settings menu.
  2. Scroll to Developer Options.
  3. Confirm that ADB debugging is enabled.
  4. Enable Debug over Bluetooth.

Enable Bluetooth debugging on the phone


    1. On the phone, open the Android Wear companion app.
    2. Tap the Settings → Debugging over Bluetooth. Next click on the “Device to Debug” and select your devices.
    3. Then a status message appears under the option. It looks like this:
      Host: disconnected
      Target: connected
      At this point the development machine (the host) is not communicating with with the watch (the target). You need to complete the link.

      Connect the debugger to the watch

      In this final step, you'll use everything: the debugger, the phone, and the watch.
      1. Connect the phone to your development machine with a USB cable.
      2. Run these two commands in the debugger:
        adb forward tcp:4444 localabstract:/adb-hub
        adb connect 127.0.0.1:4444
         
        Note: You must use the IP address 127.0.0.1. You can use any available port on your development machine. Be sure you use the same port in both commands. (In this example the port is 4444.)
      3. After you type the connect command, look at the watch. It will ask you to confirm that you are allowing ADB Debugging.
      4. Go back to the phone and check the status display in the Android Wear companion app. It should look like this:
        Host: connected
        Target: connected
         
         Android Wear Status - Debugging over bluetooth
         
         
      5. The watch is now connected to the debugger and you're ready to start debugging.
      When you debug a watch using Bluetooth, adb always uses the IP address 127.0.0.1 plus the port that you assigned. Therefore, all adb commands use this format (continuing the example, the port is 4444):
      adb -s 127.0.0.1:4444 <command> 
       
      If you are not using the emulator and have only one device connected for debugging, you don't need to specify the address at all:
      adb <command>
       
       

      Once after above setup is done then it should show two(phone and watch) devices as below : 

      ~$ adb devices
      List of devices attached 
      9887b7394b30585930 device
      127.0.0.1:4444 device
       
      To connect exactly android wear device :
      ~$ adb connect 127.0.0.1:4444
      connected to 127.0.0.1:4444
       
       
      In Linux terminal use following commands to get wearable logs:
      $ adb -s 127.0.0.1:4444 logcat *:i|grep -i "your project package name"
      ~$ adb -s 127.0.0.1:4444 logcat 
       
      Global Options Description
      -a Listen on all network interfaces instead of only on localhost.
      -d Direct an adb command to the only attached USB device. Returns an error when more than one USB device is attached.
      -e Direct an adb command to the only running emulator. Returns an error when more than one emulator is running.
      -s serial_number Direct an adb command to a specific device, referred to by its adb-assigned serial number (such as emulator-5556). Overrides the serial number value stored in the $ANDROID_SERIAL environment variable. See Send Commands to a Specific Device.
      -H server The name of the adb server host. The default value is localhost.
      -P port The adb server port number. The default value is 5037.
      -L socket Listen on the provided adb server socket. The default value is tcp:localhost:5037.

      No comments:

      Post a Comment

      Could not identify launch activity: Default activity not found : Error while Launching activity

      Problem : I got this Error , When I tried to create an application without any Activity . Basically like to develop an Android Headless appl...