Search Unity

Setting up mobile device with PC without cable for multiple purposes (build, ide code testing etc).

Discussion in 'Community Learning & Teaching' started by YasinJavaid_, Dec 18, 2019.

  1. YasinJavaid_

    YasinJavaid_

    Joined:
    Jul 15, 2016
    Posts:
    3
    Connect mobile device for build/debug code in IDE(Mono,VS, Rider etc) without cable
    Live build code debugging in IDE.

    Here is how to do follow the following step:

    Required
    Google Sdk or PlatfomTools and if adb didn't work use .\adb

    Steps

    1) Both PC and mobile device connected to same network. (to check both have same network their Ip address have same Class A and Class B ie 172.16.1.43 & 172.16.2.26).

    2) Connect mobile device to PC via cable for once.

    • USB mode must be PTP in order for ADB to work. You can usually change this from the notification shade
    • Make sure to allow USB debugging if a pop-up appears
    3) Open "PowerShell Window" in SDK\platform-tools folder or downloaded platformtools Click Shif-Key + Right-Click on mouse than select "Open PowerShell window here" or "Open command prompt here".

    4) Get IP of mobile device in mobile settings\about phone\ status\IP address or in with command "adb shell ip addr show wlan0" on some powershells use ".\adb" instead of "adb"
    150154-capture.png

    5) Ping Device "ping DeviceIP (must be have ping to your device I.e 172.16.2.26)" you get response from device.
    see bellow (figure 1.0 - 1)

    6) Revoke USB connection "adb usb".
    see bellow (figure 1.0 - 2)

    7) Listening port "adb tcpip 5556" any port 5555 or 55xx.
    see bellow (figure 1.0 - 3)

    Figure 1.0
    2.PNG

    *if listen port not working showing message ".......... the target machine actively refused it"
    then "adb kill-server". repeat all steps from 1.

    8) Connect mobile device with IP address "adb connect 172.16.2.26:5556"
    see bellow (figure 2.0 - 1)

    9) Disconnect phone from USB cable
    • Check same WIFI connection with to device.
    10) Check connected devices type "adb devices".
    see bellow (figure 2.0 - 2)
    Figure 2.0
    3PNG.PNG

    our device is connected with PC without cable.

    11) In Unity editor open build settings and click refresh button then select your devices. if using old unity then direct build and run.
    Capture.PNG


    Ide(visual studio) code debugging on live build.

    • In build settings check "development build" and "Scripts Debugging" then build it because Visual studio didn't attach to mobile process. see bellow (figure 3.0 - 1)
    • in Visual studio add break points if you didn't add it before, after success of build open attach unity debugger from top window bar "Debug\Attach Unity Debugger" on popup panel select your mobile device and start debugging on live build. see bellow (figure 3.0 - 2)
    Figure 3.0
    Capture.PNG
     
  2. YasinDev

    YasinDev

    Joined:
    Nov 2, 2018
    Posts:
    1
    For Macbook use $ sign before every command.
     
  3. dielenamaria

    dielenamaria

    Joined:
    Aug 29, 2020
    Posts:
    1
    Hi! I'm having problems to use this workflow with the Oculus Quest which is an Android device.

    Before trying development with Unity, I already used adb connect and scrcpy to stream the VR image wirelessly to my Mac. Therefore I know that the wireless adb connection to the Quest usually is very reliable.

    If I follow the directions until step 10 (Check connected devices type "adb devices".) I can see the quest as a connected device. But as soon as I continue to step 11 (In Unity editor open build settings and click refresh button then select your devices) the connection is dropped and adb devices does not list the Quest any more.

    It seems that Unity internally runs "adb usb" as mentioned in this thread from 2015. There also was a feature request, but since the Feedback website was closed down in 2019, I can't see the current state. (There is a snapshot of the page from 2015).

    Does anyone know a workaround or if the feature request was accepted back then?
     
  4. YasinJavaid_

    YasinJavaid_

    Joined:
    Jul 15, 2016
    Posts:
    3
    use different port while connecting. i connect and my devices connected in editor.
     
  5. robin_pcity

    robin_pcity

    Joined:
    Jun 26, 2020
    Posts:
    28
    Hey, do you know if the folder "program-files" needs to have certain location?
    Honestly, there should be a tutorial for that or an official document about