Can't debug on Android - breakpoint seems to be hit on target, but not in VS

Hi all,

I’m currently trying to debug my mobile project on Android, and am having issues.

What seems to be happening is that when I hit my breakpoint while running on the target, the app freezes on the phone (like I’m hitting a breakpoint), but in visual studio, it seems like I’m not hitting a breakpoint at all (no control is passed). My breakpoint is “filled in”, and I’m connecting to the target via VS’s Debug->Attach Unity Debugger-> select phone from dialog method. The app running on the phone hangs until I force quit it (most likely sitting at the breakpoint and awaiting control from VS), but VS doesn’t seem to have any idea that this is the case.

Originally I thought that it may have something to do with my tools, so I updated VS2017 community to its most recent offerings: VS 15.9.12 with Visual Studio tools for Unity 3.9.0.3, but this had no affect. I’m currently on Unity 2019.1.5f1.

Interestingly, I tried to debug a fresh project created with 2019.1.5f1, and I was able to hit my breakpoint on the android target with no issue, so it seems I’ve limited the problem to something to do with my project. The obvious things are set correctly, like a development build and script debugging turned on. This project was originally created a long time ago, and I’ve been upgrading it with Unity over time. I do not recall the last time I’ve successfully debugged an android target with this project, as I’ve mainly been able to get by with looking for exceptions in logcat output.

Anyone run into something like this before?

Thanks,
Davis

Edit: As another data point, if I attach to the target with no breakpoints set, and then set a breakpoint on an Update() call of an object in the current scene, before the breakpoint can resolve to filled, both VS and the target will lock up. VS is totally unresponsive (no clicks or input registering at all), and only resumes normal operation when I force quit the application on the phone.

In an attempt to build on my fresh project being able to debug, I just tried to recreate my project by creating a fresh 3d project, and then bringing in my assets. I didn’t copy over any project settings, and allowed 3rd parties to be either re-downloaded from asset store, reinstalled by unity package, or pulled by internal processes (unity services tab). I got a buggy version of my project up and running, but the same issue is persisting.

Scratching my head here…

Did you have any luck with this? I’m currently having the same issue and can’t seem to find a solution anywhere.

Just fixed my problem. Hope this helps.

In Project Settings → Player → Other Settings I had the C++ Compiler Configuration set to “Release” and in VS I was targeting “Debug”. That’s why it couldn’t debug properly. I changed it back to Debug and now it works like a charm.

5 Likes

This only solution worked for me, you saved my day
Btw in my huge project it only works with such setup:
Backend → IL2CPP (obviousely)
C++ compiler config - Debug
IDE - Visual Studio 2019. (Rider is not working with IL2CPP properly, as far as I know)