Environment
Describe the bug
When running the following command to install Android AVDs:
@powershell -NoProfile -ExecutionPolicy Bypass -Command "iex ((new-object net.webclient).DownloadString('https://nativescript.org/setup/win-avd'))"
I get this:
Cannot find an overload for "Combine" and the argument count: "4".
At line:2 char:44
+ $androidExecutable = [io.path]::combine <<<< ($env:ANDROID_HOME, "tools",
"bin", "sdkmanager")
+ CategoryInfo : NotSpecified: (:) [], MethodException
+ FullyQualifiedErrorId : MethodCountCouldNotFindBest
Cannot find an overload for "Combine" and the argument count: "4".
At line:3 char:47
+ $avdManagerExecutable = [io.path]::combine <<<< ($env:ANDROID_HOME, "tool
s", "bin", "avdmanager")
+ CategoryInfo : NotSpecified: (:) [], MethodException
+ FullyQualifiedErrorId : MethodCountCouldNotFindBest
Do you want to install Android emulator? (Y)es/(N)o: y
Setting up Android SDK system-images;android-28;google_apis;x86...
'system-images' is not recognized as an internal or external command,
operable program or batch file.
'extras' is not recognized as an internal or external command,
operable program or batch file.
Cannot find an overload for "Combine" and the argument count: "5".
At line:17 char:50
+ $haxmSilentInstaller = [io.path]::combine <<<< ($env:ANDROID_HOME, "e
xtras", "intel", "Hardware_Accelerated_Execution_Manager", "silent_install.bat"
)
+ CategoryInfo : NotSpecified: (:) [], MethodException
+ FullyQualifiedErrorId : MethodCountCouldNotFindBest
'create' is not recognized as an internal or external command,
operable program or batch file.
ERROR: An error occurred while installing Android emulator. Please, install it m
anually.
To Reproduce
I followed the instructions in Advanced Setup Guide in NativeScript website. I didn't install packages online. I downloaded them separately and copied them to corresponding temp folders so chocolatey could find them. I didn't install AVDs that day. Running tns doctor returned a checkmark.
Expected behavior
It should install Android AVDs.
Edit
By running tns doctor, I get:
√ Getting environment information
No issues were detected.
√ Your ANDROID_HOME environment variable is set and points to correct directory.
√ Your adb from the Android SDK is correctly installed.
√ The Android SDK is installed.
√ A compatible Android SDK for compilation is found.
√ Javac is installed and is configured properly.
√ The Java Development Kit (JDK) is installed and is configured properly.
√ Local builds for iOS can be executed only on a macOS system. To build for iOS on a different operating system, you can use the NativeScript cloud infrastructure.
√ Getting NativeScript components versions information...
√ Component nativescript has 5.0.1 version and is up to date.
By running avdmanager list, I get:
Available Android Virtual Devices:
The following Android Virtual Devices could not be loaded:
Name: Android_Accelerated_x86_Nougat
Path: C:\Users\Mojtaba\.android\avd\Android_Accelerated_x86_Nougat.avd
Error: Missing system image for Google APIs x86 Android_Accelerated_x86_Nouga
t.'
Parsing C:\Android\android-sdk\build-tools\28.0.3\package.xmlParsing C:\Android\
android-sdk\emulator\package.xmlParsing C:\Android\android-sdk\extras\android\m2
repository\package.xmlParsing C:\Android\android-sdk\extras\google\m2repository\
package.xmlParsing C:\Android\android-sdk\patcher\v4\package.xmlParsing C:\Andro
id\android-sdk\platform-tools\package.xmlParsing C:\Android\android-sdk\platform
s\android-28\package.xmlParsing C:\Android\android-sdk\tools\package.xmlAvailabl
e devices definitions:
id: 0 or "tv_1080p"
Name: Android TV (1080p)
OEM : Google
Tag : android-tv
---------
id: 1 or "tv_720p"
Name: Android TV (720p)
OEM : Google
Tag : android-tv
---------
id: 2 or "wear_round"
Name: Android Wear Round
OEM : Google
Tag : android-wear
---------
id: 3 or "wear_round_chin_320_290"
Name: Android Wear Round Chin
OEM : Google
Tag : android-wear
---------
id: 4 or "wear_square"
Name: Android Wear Square
OEM : Google
Tag : android-wear
---------
id: 5 or "Galaxy Nexus"
Name: Galaxy Nexus
OEM : Google
---------
id: 6 or "Nexus 10"
Name: Nexus 10
OEM : Google
---------
id: 7 or "Nexus 4"
Name: Nexus 4
OEM : Google
---------
id: 8 or "Nexus 5"
Name: Nexus 5
OEM : Google
---------
id: 9 or "Nexus 5X"
Name: Nexus 5X
OEM : Google
---------
id: 10 or "Nexus 6"
Name: Nexus 6
OEM : Google
---------
id: 11 or "Nexus 6P"
Name: Nexus 6P
OEM : Google
---------
id: 12 or "Nexus 7 2013"
Name: Nexus 7
OEM : Google
---------
id: 13 or "Nexus 7"
Name: Nexus 7 (2012)
OEM : Google
---------
id: 14 or "Nexus 9"
Name: Nexus 9
OEM : Google
---------
id: 15 or "Nexus One"
Name: Nexus One
OEM : Google
---------
id: 16 or "Nexus S"
Name: Nexus S
OEM : Google
---------
id: 17 or "pixel"
Name: Pixel
OEM : Google
---------
id: 18 or "pixel_c"
Name: Pixel C
OEM : Google
---------
id: 19 or "pixel_xl"
Name: Pixel XL
OEM : Google
---------
id: 20 or "2.7in QVGA"
Name: 2.7" QVGA
OEM : Generic
---------
id: 21 or "2.7in QVGA slider"
Name: 2.7" QVGA slider
OEM : Generic
---------
id: 22 or "3.2in HVGA slider (ADP1)"
Name: 3.2" HVGA slider (ADP1)
OEM : Generic
---------
id: 23 or "3.2in QVGA (ADP2)"
Name: 3.2" QVGA (ADP2)
OEM : Generic
---------
id: 24 or "3.3in WQVGA"
Name: 3.3" WQVGA
OEM : Generic
---------
id: 25 or "3.4in WQVGA"
Name: 3.4" WQVGA
OEM : Generic
---------
id: 26 or "3.7 FWVGA slider"
Name: 3.7" FWVGA slider
OEM : Generic
---------
id: 27 or "3.7in WVGA (Nexus One)"
Name: 3.7" WVGA (Nexus One)
OEM : Generic
---------
id: 28 or "4in WVGA (Nexus S)"
Name: 4" WVGA (Nexus S)
OEM : Generic
---------
id: 29 or "4.65in 720p (Galaxy Nexus)"
Name: 4.65" 720p (Galaxy Nexus)
OEM : Generic
---------
id: 30 or "4.7in WXGA"
Name: 4.7" WXGA
OEM : Generic
---------
id: 31 or "5.1in WVGA"
Name: 5.1" WVGA
OEM : Generic
---------
id: 32 or "5.4in FWVGA"
Name: 5.4" FWVGA
OEM : Generic
---------
id: 33 or "7in WSVGA (Tablet)"
Name: 7" WSVGA (Tablet)
OEM : Generic
---------
id: 34 or "10.1in WXGA (Tablet)"
Name: 10.1" WXGA (Tablet)
OEM : Generic
Available Android targets:
----------
id: 1 or "android-28"
Name: Android API 28
Type: Platform
API level: 28
Revision: 6
By running tns run android --emulator, I get:
Skipping node_modules folder! Use the syncAllFiles option to sync files from this folder.
Searching for devices...
Starting Android emulator with image Android_Accelerated_x86_Nougat
Cannot find connected devices.
Emulator start failed with: Cannot run the app in the selected native emulator.
Try to restart the adb server by running the `adb kill-server` command in the Command Prompt, or increase the allocated RAM of the virtual device through the Android Virtual Device manager. NativeScript CLI users can try to increase the timeout of the operation by adding the `--timeout` flag.
To list currently connected devices and verify that the specified identifier exists, run 'tns device'.
To list available emulator images, run 'tns device <Platform> --available-devices'.
Running emulator -avd tv_720p, gets me (tv_720p is in the list of Available devices definitions):
PANIC: Unknown AVD name [tv_720p], use -list-avds to see valid list.
HOME is defined but there is no file tv_720p.ini in $HOME\.android\avd
(Note: Directories are searched in the order $ANDROID_AVD_HOME, $ANDROID_SDK_HOME\avd, and $HOME\.android\avd)
By running emulator -list-avds, I get:
So, it seems that devices listed on avdmanager list's output, aren't installed.
So, did you download everything outside of the chocolatey install process?
It looks like steps 5 and 6 did not run from the advanced setup guide you mentioned. Try running those commands if chocolatey is installed.
A quick way to check and see if the android tools are installed is run avdmanager or sdkmanager in your command line and see if that does anything.
Also, what is the output when you run tns doctor? It should have ~ 20 lines of things that are checked.
@PythonDevOp Yes, I downloaded everything outside the process of chocolatey.
All steps including steps 5 (installing Android SDK) and 6 (installing all packages for the Android SDK Platform 28, Android SDK Build-Tools 28.0.3 or later, Android Support Repository, Google Repository, etc), except step 7 (installing AVDs) are done correctly; at least that's what tns doctor tells me.
Please see my edit.
Based on that output, it _appears_ that everything worked how it should during the install, save for one device that could not be installed (Android_Accelerated_x86_Nougat). This should be fixed if you install the SDK's and appropriate build tools for that avd. Is this the one you need to use??
Other than that It appears that you have a whole list of devices installed. Have you tried to create a nativescript application and run it on one of them? Instructions can be found here and here for that.
As to what failed, and why, I can't tell you. Try to create an app and run it on one of the AVD's listed and see what happens. Basically, once the device is running, perform a tns run android and it _should_ automatically find the emulated device and install the app on it.
@PythonDevOp
Is this the one you need to use??
I didn't set that device. I think it's the default one. Honestly I just want to run my app on some mobile/tablet AVDs.
Other than that It appears that you have a whole list of devices installed.
Those are listed as "Available devices definitions". Aren't they just definitions? Shouldn't I install those devices somehow?
Please see my edit.
Those are listed as "Available devices definitions". Aren't they just definitions? Shouldn't I install those devices somehow?
That depends on what gets installed during the AVD install process when you run the powershell command :) Since you ran everything manually, and something broke during that process, its hard to say. I would think that the command has a set list of AVD's and packages it installs. I don't have a bare Windows machine to test that theory, but someone from the NativeScript team might have that answer. According to the docs running the avdmanager list command shows what is installed. In order to run, you must have the necessary build tools etc.
Run these commands:
sdkmanager "system-images;android-25;google_apis;x86" "system-images;android-28;google_apis;x86"
and then:
avdmanager create avd -n test -k "system-images;android-28;google_apis;x86"
This should install the SDK's for Android 28 (to fix the nougat issue) and 25, create an AVD named "test". From there, you should be able to type tns run anrdoid and it should bring up the "test" avd and install the app on it.
I don't think this is a NativeScript issue, but rather a local system configuration issue. If things don't work after that, I am not sure what else to say. If you don't want to go through the pain of troubleshooting the issue, I would suggest using Genymotion and running your app on that.
@mrmowji try to manually create an AVD. I guess your setup does not have an Android Studio so you could directly create an AVD with the available system-images. In case you don't have a system image for creating a specific emulator, you can download them manually (e.g. here).
The grab the path to the system-images and create the AVD. For example something like:
avdmanager create avd --force --name testAVD --abi google_apis/X86_64 --package ‘path-to-system-image’
After the system image is downloaded and installed you can check for existing emulators with
emulator -list-avds
and start the emulator with the NativeScript command
tns run android
Closing the issue as it is not related to NativeScript modules and seems related to a local configuration issue but still please do let me know if you need further assistance.
@NickIliev @PythonDevOp Thanks. I tried installing system images and then created an AVD and it worked. But still, according to the docs, this process should be taken care of when running that PowerShell command in an automatic manner :). Hope someone (I'm not an expert) edit that page and include detailed version of these instructions.
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Most helpful comment
That depends on what gets installed during the AVD install process when you run the powershell command :) Since you ran everything manually, and something broke during that process, its hard to say. I would think that the command has a set list of AVD's and packages it installs. I don't have a bare Windows machine to test that theory, but someone from the NativeScript team might have that answer. According to the docs running the
avdmanager listcommand shows what is installed. In order to run, you must have the necessary build tools etc.Run these commands:
sdkmanager "system-images;android-25;google_apis;x86" "system-images;android-28;google_apis;x86"and then:
avdmanager create avd -n test -k "system-images;android-28;google_apis;x86"This should install the SDK's for Android 28 (to fix the nougat issue) and 25, create an AVD named "test". From there, you should be able to type
tns run anrdoidand it should bring up the "test" avd and install the app on it.I don't think this is a NativeScript issue, but rather a local system configuration issue. If things don't work after that, I am not sure what else to say. If you don't want to go through the pain of troubleshooting the issue, I would suggest using Genymotion and running your app on that.