Search code examples
xamarin.formsdeploymentxamarin.androidsony-smartwatchsamsung

Xamarin.Forms/Xamarin.Android deploy app on a physical smartwatch device


My question

I would like to know if any of you know how to put a Xamarin.Forms/native Xamarin.Android application from Visual Studio on a physical smartwatch. I have consulted various sources, but have not made any progress. Also in Visual Studio, the smartwatch does not appear in the list of connected devices. The smartwatch is a Samsung Galaxy Watch4 and runs on Wear OS 3.2 (Wear OS 3 is again based on Android 11). I also connected the smartwatch to my laptop via a bluetooth connection, but despite this connection I still don't see the device listed (I tried it in both a Xamarin.Forms project and a native Xamarin.Android project). Furthermore, I activated the Developer Options on both the smartwatch and the smartphone, with USB debugging turned on. On the smartwatch I also turned on the 'Debug via Bluetooth' option just in case.

Required SDK tools are installed in Visual Studio, the smartwatch is linked to a Samsung smartphone. Transferring the Visual Studio app to the smartphone works without any problems, but how to put the app on a smartwatch is still the question. Installed SDK Tools

Relevant software and hardware I use

  • Visual Studio 2022
  • Physical device: Samsung Galaxy Watch4 (runs on Wear OS 3.2 and Wear OS 3 is based on Android 11)
  • Samsung Galaxy S10+ (runs on Android 12, but I don't think this version number should cause any problem for the smartwatch, as I can pair them together, just don't know how to get the app on the smartwatch...)
  • Galaxy Wear App is used to pair the smartwatch with the smartphone

What I have already found or tried

In the documentation from Microsoft I also tried to follow the steps Debug on a Wear Device But when I get to step 4 then the first command works but on the second I get an error that the connection could not be established. If I try to run the same command again, I get another message saying that there is already a connection. CMD messages

After that I can't get any further in the documentation, since the following commands only work if 127.0.0.1:4444 is not 'offline' but has the status 'device'.

In another Microsoft documentation for native Xamarin.Android wearable apps 'supposedly' the physical device should automatically be in the list of connected devices, but in this project the device is not listed, despite the bluetooth connection between my laptop and the smart watch.. Run the Android Wear app

I would really appreciate if any of you know how to do this.. Thanks for the help.


Solution

  • Update: 14-03-2022 15:20 [Issue solved]

    I still don't know how to get the app from Visual Studio to the smartwatch via a bluetooth connection, despite following the documentation (if anyone does, please let me know). That's why I looked into how to make this work over a WiFi connection.

    How did I fix it?

    1. Enable 'Debugging over Wi-Fi' on your smartwatch device (after having Debugger Options enabled Enable Debugger Options. P.S. Somehow they're referring to build number, but you should press 5 times on 'Software Version Number', not 7 times)
    2. Download Android SDK Platform tools (to be able to use commands like 'adb')
    3. Extract the file and save it somewhere on your computer's hard drive
    4. Start the 'CMD' program in Windows
    5. Go to (cd [..location....]) the folder where the 'adb.exe' is located (i.e. the location where you extracted the first file)
    6. To confirm whether or not you are connected, you can run the following command: adb devices
    7. Connect the smartwatch to the same WiFi network as your PC/laptop on which Visual Studio is located and check your IPv4 address on the smartwatch
    8. If there is poor WiFi range/no WiFi nearby, you could also create a WiFi hotspot from your laptop to make this work
    9. In Windows search for the 'Mobile Hotspot' feature
    10. Enable the option: 'Share my internet connection with other devices'
    11. Connect the smartwatch to this self-created network
    12. Now that the smartwatch is connected, you can go back to the CMD screen
    13. Take the IPv4 address of the smartwatch and run the command as follows: adb connect [insert the IPv4 address in between and remove the parentheses]
    14. Run the command again: adb devices
    15. You will now see that it says under 'attached' -> device, next to the name of your smartwatch device
    16. If you now look in Visual Studio, you should see the smartwatch device and you can put the app on your smartwatch
    17. If you want to neglect all connections, you can use the following command: adb kill-server

    Now you no longer need to connect your smartphone to your laptop/PC with a USB connection or via WiFi, because you can now access the smartwatch directly via the internet connection.