Nativescript project running with Visual Studio Emulator
Asked Answered
P

1

7

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.

Popedom answered 16/10, 2017 at 16:12 Comment(0)
D
16

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

Daley answered 15/12, 2017 at 10:52 Comment(5)
You 're a little god !Porous
Sorry ^^! what do you meanDaley
you saved me lot's of time of searching how to setup Visual studio emulator properly ... nice jobPorous
I'm glad to help you ^^Daley
Sadly i can't get this to work, i installed the SDK with android studio so its located under "C:\Users[user]\AppData\Local\Android\Sdk", i have added the registry entry but the emulator, the "adb devices -l" still yields a empty list, i have restarted both the server and the entire computer, i have tried multiple android images in the emulator.Sulphurbottom

© 2022 - 2024 — McMap. All rights reserved.