See the Unity Documentation for details Unity - Manual: Debugging on an Android device (unity3d.com).


Recommended setup:

  1. Connect the Android device to a computer via cable. 
  2. Activate adb WiFi and make sure that both devices are connected via the same wireless network, then disconnect the Android device from the cable. Optionally adb via cable can be used as well.
  3. In the build settings select the options and build the app:
    • Development Build
    • Script Debugging
    • Wait For Managed Debugger (optional) must only be enabled when using https://docs.spaces.qualcomm.com/unity/setup/dual-render-fusion-overview. Upon starting the application, a popup waiting for a debugger will show up in the glasses. For some devices, this window will not go away even if a debugger is connected, and debugging is not possible. When using Dual Render Fusion, the popup will instead be displayed on the phone where it can be navigated by touch. 
    •  
  4. The Android logcat can be used for debugging with logs. There is a logcat package available in Unity's Package Manager Android Logcat Guide | Package Manager UI website (unity3d.com)
  5. If Script Debugging was enabled, breakpoints and full debugging functionality within IDEs such as Microsoft Visual Studio or JetBrains Rider can be used.
  6. Attach a debugger:
    • For Visual Studio select Debug > Attach Unity Debugger, then choose the process running on your Android device. 
    • For Rider select Run > Attach to Unity Process..., then choose the process running on your Android device.

Troubleshooting

  • The Meta Quest Plugin can prohibit internet connections and block debugging via adb Wi-Fi. Open the Meta Quest Support window in the Project Settings under XR Plug-in Management > OpenXR and selecting the gear in the Meta Quest Support column. Uncheck the Force Remove Internet Permission checkbox. This option can influence the build even if Meta Quest Support is disabled. Unity has fixed this bug in OpenXR plugin 1.9.1, and Snapdragon Spaces integrates this fix starting 0.19.1.