Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice
  4. Dismiss Notice

Cannot debug on device: connection refused

Discussion in 'Android' started by Falondrian, Feb 15, 2018.

  1. Falondrian

    Falondrian

    Joined:
    Nov 1, 2017
    Posts:
    72
    Hello, I am having trouble debugging my App on an Android device via Mono/VS on a PC.

    - Device: Samsung Galaxy S6 (SM-G920F, Android 7.0)
    - The device is properly connected to adb via WiFi, logcat works flawlessly.
    - Firewall and antivirus disabled on both, Windows PC and Smartphone.
    - The smartphone is in developer mode with USB debugging enabled and my app is selected as the debug target in the developer menu.
    - I verified multicast is working properly in my network.
    - PC and smartphone can reach each other (ping)
    - The device properly shows up in the IDEs Attach Debugger menu.
    - The build is a development build with script debugging enabled, device filter FAT, runtime .net 3.5 equivalent, backend mono

    When trying to attach the debugger, the following happens:
    - Mono: Error-message "Could not connect to the debugger". When attaching a debugger to Mono, the following Exception pops up: System.Net.Sockets.SocketException: 'No connection could be made because the target machine actively refused it 192.168.1.136:56921'

    - VS 2017: Nothing happens. When attaching a debugger to VS, the following is printed to the output:
    Exception : Unable to start program 'Unity'. Operation not supported. Unknown error: 0x80004005.

    Please help, I already invested a lot of time into something that should be working from the start - this makes Unity unusable for me.
     
  2. Falondrian

    Falondrian

    Joined:
    Nov 1, 2017
    Posts:
    72
    So this is funny, I left the PC in standby for 2 hours, and now its working, out of the blue, no changes done - what is this black magic? Were to many ports used up from trying to fix this all day? Please Unity, improve the error handling and give better error messages!
     
  3. Falondrian

    Falondrian

    Joined:
    Nov 1, 2017
    Posts:
    72
    The issue appeared again after I switched the project to il2cpp - maybe this was the issue I had above because I did play with this setting before. I tried switching between il2cpp and mono three times, each time debugging the mono version worked, il2cpp never (fresh project). Can someone reproduce this?

    Also: .net 4.6 + mono causes the app to crash on startup for me (I guess this issue: https://issuetracker.unity3d.com/is...-android-to-crash-on-startup-with-net-4-dot-6). This leaves me with the only option: .net 3.5 + mono...
     
    Last edited: Feb 16, 2018
  4. Tomas1856

    Tomas1856

    Unity Technologies

    Joined:
    Sep 21, 2012
    Posts:
    3,669
  5. Falondrian

    Falondrian

    Joined:
    Nov 1, 2017
    Posts:
    72
    @Tomas1856: thanks, all of that is properly set up, it's not the issue. I am waiting for someone to reproduce the il2cpp debugging issue and will then file a bug report.
     
  6. Fishing_Cactus

    Fishing_Cactus

    Joined:
    Nov 8, 2014
    Posts:
    45
    Same issue here... switching to mono backend allowed us to attach the debugger...