You can debug Unity players with Visual Studio and UnityVS since version 1.2.
In this post we’ll see how to debug the AngryBots game under the Android platform.
Java & Android Setup
Do not use the latest Android SDK, as there are some changes on Google side that broke Unity's build process with 4.x.
I’m not sure that it was fixed with the latest Unity version (i'm using 4.1.5f1) so here is my working setup :
- Install Java v1.7.0.21 x86 (even if you have a 64 bits OS)
- Install android SDK version r20. you can download it here : http://dl.google.com/android/installer_r20-windows.exe
- Run the SDK Manager, then download SDK Tools, SDK Platform Tools and Android 4.0 (API 14)
- NEVER update SDK Tools nor SDK Platform Tools, keep revisions 20/12.
Networking setup
Use a wireless local network and be sure to properly setup your access point and operating system firewalls to accept TCP and UDP communication with your android device.
Alternatively you can use an AdHoc Wifi connection between your computer and your device.
Building and installing the APK
Switch to the Android build platform and check "Development Build" and "Script Debugging" options so we can connect to the engine and debug the game.
Then install the generated package using « adb install » (you can use an USB cable for this step if you have issues using adb over WiFi).
Debugging from VisualStudio
Launch the game on your device, then use « Attach Unity Debugger » from the Visual Studio Debug menu.
UnityVS will now display all engines able to communicate. As you can see my local Unity editor is responding, as well as my android device (Samsung Galaxy S3).
Let’s put a breakpoint when a spider explode.

Play with your device, and when the breapoint is hit, you can debug your game as usual.
I’m using a Samsung Galaxy S3 with Android v4.1.2, so my Unix Kernel is 3.0.31.764725 (you can check this with « About device » menu).
Let’s check this version using Visual Studio and the Watch window.
Happy debugging with UnityVS !
Commentaires