Forum Visual Studio

Sometimes Visual Studio doesn't show connected devices

igorkr_10igorkr_10 Member ✭✭✭✭
edited October 2019 in Visual Studio

Hi!
Sometimes when I launch my project I can't see any connected device instead of "Android Emulator".

"Normal" behavior that I expected is:

Also output with normal behavior is:

[D:]: $(MonoAndroidToolsDirectory) path C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\MSBuild\Xamarin\Android is valid
[D:]: $(MonoAndroidBinDirectory) path C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\MSBuild\Xamarin\Android is valid
[D:]: mscorlib.dll path C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\Common7\IDE\ReferenceAssemblies\Microsoft\Framework\MonoAndroid\v1.0 is valid
[D:]: GetSdkPath C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\MSBuild\Version.txt exists=False
[D:]: GetSdkPath C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\MSBuild\Version exists=False
[D:]: GetSdkPath C:\Program Files (x86)\Microsoft Visual Studio\Version.txt exists=False
[D:]: GetSdkPath C:\Program Files (x86)\Microsoft Visual Studio\Version exists=False
[D:]: GetSdkPath C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\MSBuild\Xamarin\Android\Version.txt exists=False
[D:]: GetSdkPath C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\MSBuild\Xamarin\Android\Version exists=True
[D:]: FindVersionFile: C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\MSBuild\Xamarin\Android\Version, result=True
[I:]: Found Xamarin.Android 10.1.0.1
[I:sdk]: Runtime path: C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\MSBuild\Xamarin\Android
[I:sdk]: Framework path: C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\Common7\IDE\ReferenceAssemblies\Microsoft\Framework\MonoAndroid\v1.0
[D:]: ValidateAndroidSdkLocation: C:\Program Files (x86)\Android\android-sdk, result=True
[D:]: ValidateAndroidNdkLocation: ``, result=False
[I:]: Looking for Android NDK...
[I:]: Looking for Android SDK...
[D:]: ValidateAndroidSdkLocation: C:\Program Files (x86)\Android\android-sdk, result=True
[D:]: ValidateJavaSdkLocation: C:\Program Files\Android\Jdk\microsoft_dist_openjdk_1.8.0.25, result=True
[I:]: Tracking android devices started
[D:]: Tracking avd started
[D:]: avd watcher *.ini path: 'C:\Users\Igor.android\avd'
[D:]: avd watcher: got device list from avd with 4 devices
[W:]: Adb connection refused
[I:]: Starting Adb server (adb start-server)
[I:]: Looking for Android SDK...
[D:]: ValidateAndroidSdkLocation: C:\Program Files (x86)\Android\android-sdk, result=True
[W:]: AutoSdk cannot resolve dependencies: [email protected]
[I:]: Adb start-server operation completed
[D:]: TrackDeviceTask got: ce0718272c2c6e1c04 device
[I:]: Got new device list from adb with 1 devices
[D:RunShellCommand]: ce0718272c2c6e1c04 getprop

Tagged:

Answers

  • ClintStLaurentClintStLaurent USUniversity ✭✭✭✭✭

    We/I see that on occasion too. It happens when I bounce back and forth between different tables and USB & Wifi debugging.
    Make a couple batch files and keep them handy on your desktop
    You will have to adjust the path to the Android SDK tools. You want the folder with adb.exe
    So it depends on where you installed Android/java

    Reset the ADB

    c:
    cd C:\Users\{you}\AppData\Local\Android\Sdk\platform-tools
    
    adb kill-server
    @echo off
    echo killing server!
    @echo on
    Timeout /t 3 >nul
    
    @echo off
    @echo on
    adb start-server
    @echo off
    echo starting server!
    @echo on
    Timeout /t 3 >nul 
    @echo off
    echo exiting app in 3 seconds!
    @echo on
    Timeout /t 3 >nul
    

    Debug over wifi

    The first ADB calls tell the connected device to flip to TCPip port 5555 for debugging
    Then the next call tells your PC to look at an IP:port combo for the device
    So you need to update the script with the IP of your tablet

    c:
    cd C:\Users\{you}\AppData\Local\Android\Sdk\platform-tools
    adb tcpip 5555
    @echo off
    echo Unplug usb you have 10 seconds!
    @echo on
    Timeout /t 10 >nul
    
    rem Active2 via Windows Hotspot to Clint's laptop
    adb connect 192.168.0.20:5555 
    
    ping 192.168.0.20 -t
    rem Keep pinging the tablet to confirm its still on the network
    
    @echo off
    echo exiting app in 3 seconds!
    @echo on
    Timeout /t 30 >nul
    

    Back to USB

    Flip the connected device (wifi most likely) back into USB debugging

    c:
    cd C:\Users\{you}\AppData\Local\Android\Sdk\platform-tools
    
    @echo off
    echo plug in usb you have 15 seconds!
    Timeout /t 15 >nul
    adb usb
    @echo off
    echo usb on exiting app in 3 seconds
    Timeout /t 3 >nul
    
Sign In or Register to comment.