Running Cordova Multi-Device Hybrid App from Visual Studio On Android Device

As the name suggests, in this column I am going to show you how to run and debug your hybrid application from Visual Studio on your Android device. We will not be covering iOS here but in a later post.

If you haven’t started developing Multi-Device Hybrid applications in Visual Studio then I suggest that you take a look at my previous post.

If you have attempted to run your application on your Android device and you were not successful, read on.

First of all, to run your application on your device, you need to select the “Device” mode in Visual Studio.

Device mode

When you try to run the application on your device and although your device is connected, you may see the following error:

The command ""C:UsersGeorgeAppDataRoamingnpmnode_modulesvs-mdavs-cli" prepare --platform Android --configuration Debug --projectDir . --projectName "SampleHybridApp"" exited with code 8.

As you might have noticed, it is certainly not informative and you may knock yourself out trying to find out what is going on.

Step 1: Install Android SDK Packages

You will need to locate the Android SDK installation directory such as AppDataLocalAndroidandroid-sdk and open up the SDK Manager. The manager will list the packages that are installed and those that aren’t. It will also tell you if you need to update the packages. Just review the list of packages and click Install Packages. Once the SDK Manager finishes installing the new packages, it’s time to Build the project again.

Step 2: Connect Your Device

At this point you will need to have your Android device connected via USB cable and you need to have the USB drivers installed on your computer. Although I had mine connected, I was getting the following error:

Error device not found

Step 3: Enable Developer Options and Check USB Debugging

You need to make sure that you have Developer Options enabled on your phone. On Samsung devices with the latest Android, it’s hidden by default. Once it’s enabled, you need to make sure that USB Debugging is checked.

Step 4: Android SDK and List Devices Command

Although I had USB Debugging checked on my Samsung Galaxy S4 and I was able to browse its content from Samsung Kies, I was still getting the same error.

If you’ve done any development on PhoneGap before, this may seem familiar. If not, you will be glad you’re here. Check your Environment Variables and make sure that you have the SDK and the Platform referenced in your PATH.

Path variables

Now you can open up the Command line, browse to your Platform tools installation under the SDK and try to run the “adb devices” command to list the Android devices that are connected to your machine.If you see any device listed, then luck is in your favor and you can now deploy the application to your device. If you were unlucky like me, you will see the following:

Error Unauthorized

Step 5: Stop and Start ADB Server

After looking at the android developer documentation, I realized that there is a command to kill and restart the ADB server. Simply run “adb kill-server” then “adb start-server” and now you should be able to see your device once you run “adb devices”.

adb kill start
Device list

Step 6: Run Your Application

At this point you are ready to run the application and let Visual Studio deploy it to your device. Just hit Run with Device mode selected and your application will be transfered to your device momentarily.

App on device


In a previous post we’ve seen how easy it is to get started building Hybrid apps using Visual Studio. Deploying the application and debugging it on your Android device turned out to be a different story. This is when you realize how invaluable platforms like the Telerik Platform are. They solve all the headache related to deploying and debugging your application on your device. It’s time to get back to working on my AppBuilder project.

Did you learn something? I really recommend you attend FalafelCON 2014, where there will be many deep dives into Mobile. Let me know you’re coming on Twitter!

  • Sahar Pournasseh
    September 1, 2014

    Thanks for the article, I had the same error I fixed it by changing the environment variables, but now I keep getting the error: “The command “”C:UsersSaharAppDataRoamingnpmnode_modulesvs-mdavs-cli” prepare –platform Android –configuration Debug –projectDir . –projectName “TestApps” –language “en-US”” exited with code 1. C:UsersSaharAppDataRoamingnpmnode_modulesvs-mda-targetsMicrosoft.MDA.targets 182 5 TestApps”
    for every platform! Could you please help me?

    • George Saadeh
      September 4, 2014

      Sahar, thank you for your message. Are you able to run the app in the emulator successfully? I am suspecting the drivers are not properly installed for the android device. Let me know.

  • George Saadeh
    September 4, 2014

    Nicholas, thank you for your feedback. I just posted a new post for iOS so you might want to check it out.

  • chris
    October 7, 2014

    Hi iam struggling to get the app running on the android device. I have the same errors as you mentioned above. Where do i find and change the environmental variables in vs2013?

    • Lino Tadros
      October 7, 2014

      The environment variables need to be set on the Windows machine from the Control Panel (Advanced Settings). Also make sure you have the CTP2 installed of the VS2013 Cordova templates and of course update 3 of VS.

      • chris
        October 7, 2014

        Found it. Thanks for the info

  • HarryBhasin
    February 26, 2015


    I am unable to Run Simple or Empty Cordova Project on Android Emulator and Device. When i run the project i see following error. Pl see the pic and see if u can help?


  • Gema
    June 25, 2015

    I followed all the steps but I’m stuck on Step 5, I killed the server and start it again and no matter how many times I do it the list of attached devices it’s still coming empty and my phone is connected. Also tried plugin and unplugin several times, nothing seems to work.

    I’m using an Xperia Z3 with Android 4.4.4, I’ve checked the USB debugging and it’s on. It’s probably something I’m missing on my computer because using a different computer with same phone there is no problem.

    I haven’t get to the point of trying it from visual studio but for what is worth, I’m using VS2015 CTP6.
    Please any advise.

  • hasnen dawoodji
    March 1, 2016

    Thank for this article. I have checked that all my system environment variables are in place but I still cannot debug it on an Android Device. I get the below errors. I cannot even debug it on the Emulator and at build time I get the same errors. Could you please guide me as to what am I missing and doing wrong.


Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.