Search code examples
windowsadbvisual-studio-cordova

How to convince Visual Studio to use ADB for android dev over TCP/IP


So this might be a bit of an edge case, but I'm using visual studio on a VM, and I have my phone in my hand. I'd like to set things up that when I press "play" in visual studio, it compiles my cordova app, and pushes it to my phone next to me, so I can test and debug etc.

My phone is 'rooted' and I have installed ADB wifi. I am able to connect to it from Visual Studio's adb version and also adb devices lists it.

 (output from cmd.exe running as Admin in the solution folder)

 C:\Stuff\Code\svn\myapp\MyApp>adb connect 10.10.10.6
 already connected to 10.10.10.6:5555

 C:\Stuff\Code\svn\myapp\MyApp>adb devices
 List of devices attached
 10.10.10.6:5555 device

When I press Play in Visual Studio it compiles and gets to the point where it needs to deploy to the phone and then it comes up with the following error: The system cannot find the file specified

(output from "output" tab in visual studio)

C:/Stuff/Code/svn/myapp/myApp/platforms/android/build/outputs    /apk/android-debug.apk
No scripts found for hook "after_build".
No scripts found for hook "after_compile".
------ Copying back to project: android
2>------ Deploy started: Project: MyApp, Configuration: Debug Android     ------
2>  Querying ADB for attached devices...
2>The system cannot find the file specified
2>The system cannot find the file specified
========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========
========== Deploy: 0 succeeded, 1 failed, 0 skipped ==========

Solution

  • I had a similar issue and this worked for me...


    1. adb kill-server

    2. adb tcpip 5555

    3. adb connect 10.10.10.6

    4. adb devices - should show your device

    5. Open Visual Studio as Admin

    6. Type: ALT+B, R (ALT+B then R) to rebuild your solution

    7. Run your app

    enter image description here