How can I debug Unity app running on Android device?

Answered

I have been trying to attach debugger to Unity application running on Android device, but still fail.

 

The way I use is below.

1. Connect device to PC on usb port

2. Execute terminal commands : adb tcpip 5555

3. Execute terminal commands : adb connect [ip addr of device] (PC and mobile device are connected to same network)

4. Detach device from usb port

5. Launch app on device

6. on Rider : Attach to Unity Process... and choose running app on device.

 

It seems that attaching debugger succeed. However, break points don't work, and application is not terminated but suspended.

I tried to build app with both scripting backend options, IL2CPP and Mono, but all of them results in same.

 

How can I resolve it?

If the way I used is wrong, then could you give me the manual instruction to debug Unity Android application with Rider?

9 comments
Comment actions Permalink

Hi!

Thanks for contacting us.

You described the right way to debug an application on an Android device (all points without detaching the device). Just 1,2,3, 5, 6 But this functionality had a problem until 2018.2 (RIDER-17272).

Please, try to use the latest EAP version of RIDER. If you have a problem, please contact us.

1
Comment actions Permalink

Thanks for reply.

I will try to use EAP.

0
Comment actions Permalink

A have the same issue on Rider 2019.2.2. How to resolve? Thanks in advance.

1
Comment actions Permalink

Hello, @Andreyshade84,

could you please clarify your Unity version, Operating system, Rider version?

Also, please, enable "Unity" and "Debugger" tracing in the menu "Help | Trace Scenarios (LOGS)" and reproduce the issue. Then disable tracing, compress all Rider logs via "Help | Compress Logs and Show in," file a new issue on youtrack with the attached log-archive, or send logs to us via submitting a new support request.

0
Comment actions Permalink

Hello there,

I can't seem to find a reliable way to trigger a debug session to a remote Android Unity app (Oculus Quest in fact). 

Sometimes it appears in the list after I choose "Attach to Unity Process...", sometime it doesn't. I tried everything: remote IP connection (from Rider, from the shell), changing the TCP/IP debug port, ... nothing. "Script Debugging" is of course enabled when deploying the Android app from Unity.

If I start Visual Studio Code and trigger a Remote Debug profile it connects immediately and the breakpoints work.

I'm using the last macOS (10.15.1), the last stable Unity version (2019.2.13f1) and the last Rider (2019.2.3).

Any help would be more than welcome because I just hate to have to run a Microsoft product on my Mac just to debug my stuff :P Thanks for my mental health :D

2
Comment actions Permalink

Hello Brice, 

Could you please install the latest EAP and try to perform the same. If the issue persists, then please collect the logs with Debug and Unity Trace and Sofia mentioned above and submit an issue on our tracker so we could check out why it happens. Thank you in advance!

0
Comment actions Permalink

Hello, thanks for your feedback.

It's even worse with the version 2019.3 EAP7 or Rider, even Unity Editor can't be attached anymore:

Failed to connect: Connection refused
Unable to connect to Unity Editor
Please ensure 'Editor Attaching' is enabled in Unity's External Tools settings page.

(of course Editor Attaching is enabled).

I will try to find time to make the report you asked for asap. Thanks.

0
Comment actions Permalink

I was unable to get the unity player to appear in the attach window using the adb tcpip method.

I had to disconnect adb tcpip and enable wireless debugging in the android developer settings, then connect, and allow debugging on the wireless network. I was then able to see my device in the Rider Attach to Unity Process popup.


I'm on android 11, rider 2020.3.4, and unity 2018.4

0
Comment actions Permalink

Devlinvining, have you tried to debug over WiFi or USB? Debug of Unity Android via USB is not available yet: RIDER-31578. If it is not the case, then please submit the issue on our tracker. 

0

Please sign in to leave a comment.