Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Nativescript project running with Visual Studio Emulator

I have a Nativescript application that I'm developing using VS Code and have no issues when I try to run it using the Nativescript launch configurations from the Nativescript extension, when I'm using a real device connected with USB or when I use one of the android-sdk emulators.

Now I need to run Hyper-V on the machine too and those emulators cannot run when hypervisor is on. So I downloaded and installed Visual Studio Android Emulator which runs fine when I launch it manually.

Problem is that the nativescript project doesn't recognize this device either with tns device or adb devices commands and if I try to launch the application from VS Code it tries to launch one of the other emulators, which obviously fails due to the hypervisor/Intel Haax incompatibility.

Did any of you had this problem before and have any solutions you can share?

Thanks.

like image 544
nunob Avatar asked Oct 16 '17 16:10

nunob


1 Answers

Microsoft MSDN say :

If the emulator is running, but it does not appear to be connected to ADB or it does not appear in Android tools that make use of ADB (for example, Android Studio or Eclipse), you may need to adjust where the emulator looks for ADB.

The emulator uses a registry key to identify the base location of your Android SDK, and looks for the \platform-tools\adb.exe file under that directory.


Here We Go!! Step By Step ;)

Copy Your ANDROID SDK PATH for me it look like this :

enter image description here


To modify the Android SDK path used by the emulator:

  1. Open Registry Editor by selecting Run from the Start buttons context menu, typing regedit in the dialog box, and choosing OK.

enter image description here


  1. Navigate to HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Android SDK Tools in the folder tree on the left.

Note : if Android SDK Tools folder doesn't exist, Create it under WOW6432Node, And open it, And Create a String Value name it Path:)

  1. Modify the Path registry variable to match the path to your Android SDK.

enter image description here


  1. Restart the emulator and you should now be able to see the emulator connected to ADB and associated Android tools.

enter image description here


Now! Open Your Terminal (CMD), and Run ADB command

adb devices -l

enter image description here

YES YES !! The Visual Studio Emulator is running, and connected to ADB!


HERE WE GOO !!

Now We Want To Create A Demo App (for example FIRSTZAKI) ZAKI is my nickname :p

On Terminal (CMD) :

tns create FIRSTZAKI

enter image description here

Choose Android Platform

cd FIRSTZAKI\

tns platform add android

enter image description here

Check if VS EMULATOR is ready!

tns devices

enter image description here

YES YES ^^

Finally Step (RUN/BUILD) :

tns run android

enter image description here

WOW ... Great :)

enter image description here

AND .. Good Luck ♥ — ZAKI

like image 118
zakaria chahboun Avatar answered Oct 05 '22 20:10

zakaria chahboun