Nativescript - error on tns run android - nativescript

I'm trying to run android emulator with the command tns run android. This starts the emulator but it keeps stuck on Android logo and I get the following error:
(...)
BUILD SUCCESSFUL
Total time: 17.013 secs
Project successfully built.
Using C:\(...)\sample-Groceries\platforms\android\build\outputs\apk\sampleGroceries-debug.apk
Starting Android emulator with image Nexus6
Waiting for emulator device initialization..............
Cannot run your app in the native emulator. Increase the timeout of the operation with the --timeout option or try to restart your adb
server with 'adb kill-server' command. Alternatively, run the Android
Virtual Device manager and increase the allocated RAM for the virtual
device.
(...)
Here is my Android Virtual Device configured:
AVD Manager
Note: I can run the application on my phone anyway, but not on my PC.

Finally I found the problem.
In Android Virtual Device Manager, there was an error I didn't see:
AVD Manager error

Here is a solution which I found to be useful.
enter image description here
You just have to manually activate the emulator, which you can do using android studio or command line. Using the command line, you have to run this command
emulator -avd avd_name [ {-option [value]} … ]
for ex:
/Android/sdk/emulator/emulator -avd test
Once the emulator starts you can run this command
tns run android

I started having similar issue after updating to the latest Android Studio and latest emulators. I switched the VM Heap to 64, and it worked for me. May be worth giving that a try.

Open your Android Virtual Device Manager and download the latest
emulator. That will fix the error.

I had the same problem. I fixed that by:
Open emulator manually from Android Studio (double-click on position in AVD Manager list)
Run tns run android
Works for macOS Sierra.

Related

installing reactnative for android on macOS Catlina

i try to install reactnative today
been following tutorial from here : https://reactnative.dev/docs/environment-setup
when i try to run the test project
it failed to load emulator
chandra#MacBook-Pro-Chandra AwesomeProject % npx react-native run-android
info Running jetifier to migrate libraries to AndroidX. You can disable it using "--no-jetifier" flag.
Jetifier found 967 file(s) to forward-jetify. Using 8 workers...
info Starting JS server...
/bin/sh: adb: command not found
info Launching emulator...
error Failed to launch emulator. Reason: No emulators found as an output of emulator -list-avds.
warn Please launch an emulator manually or connect a device. Otherwise app may fail to launch.
info Installing the app...
can anyone help me please? thanks
You must create at least one AVD (Android Virtual Device) in order to run it in the emulator. It seems that you don't have any. An easy way to check is to run the following command:
emulator -list-avds
# Example output
Nougat_7
Pixel_2_API_29_Google_Play_
If the output of the command is empty, it means you don't have any AVDs yet. In this case you can create an AVD by opening Android Studio and then clicking the Configure menu and after that opening AVD Manager. In AVD Manager you can create a new virtual device which you can later run in the emulator.

Can't run NativeScript app in Android emulator

I run this command:
tns run android --emulator
And I get this error:
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 --available-devices'.
I tried adb kill-server and that didn't help; I also tried the timeout thing with a setting of 60 and that didn't help either. I'm not sure how to access Android Virtual Device Manager to increase the allocated RAM. If I run tns device --available-devices I get a list of two emulated devices. How can I get the emulator set up so I can run my app?
Thanks! :)

NativeScript - cmd tns run android issue

Am new to NativeScript.
I have done Full setup ( cmd tns doctor with no issues) and created a new project by using cmd tns create.
I have installed Android studio as well, also created virtual device by AVD Manager (Pixel 3 API Q).
Now opened the project in Android Studio and run the cmd tns run android / tns run android --bundle but it throws the error "Cannot find connected devices. Reconnect any connected devices, verify that your system recognizes them, and run this command again."
cmd tns device not showing any devices but tns device android --available-devices shows devices.
Please help me how to connect device and emulators.
Also, i don't have experience in Android studio.
I'm new in Nativescript also and take me two days to configure the entire environment to run a Nativescript app with the android emulator without install the Android Studio. So the problema that you have also I had and to fix it just has to add the "ANDROID_AVD_HOME" to your system variables.
Environment variables
After that you can run your emulator only in a command line window and in another command line window without close your emulator you can type "tns device" and see the active emulators and then run your application using "tns run" or "tns run android --device emulatorname". That works for my after many attempts
Set Environment path for android emulator. First open environment variables and double click on path in system variables then open new window Edit environment variable and add emulator path in this window. Like show in this images.

react-native run-android not working and how to run it on genymotion

I just start learning react-native. when I trying to run the react-native run-android command it is showing error about android emulator.
Please help me to run my first react native app on Genymotion.
simple way:
first connect and android device or run an android emulator then do this steps
1- open android studio
2- click on File->open->navigate to to your react-native project and choose android folder
3- comeback to cmd and run react-antive order again
4- react-native run-android
in gradle-wrapper.properties change distributionUrl=https://services.gradle.org/distributions/gradle-6.3-all.zip
from 5.x
First of all you have to installed genymotion plugin on android studio. After that please run genymotion emulator.
And please open android studio and android project of created RN app.
The relevant gradle version will be downloaded and synchronized.
And then run command "react-native run-android".
Steps to setup for React Native with GenyMotion on MAC Machine
Installed Android Studio
Installed Genymotion
Pointed Genymotion settings custom SDK to: /Users/myusername/Library/Android/sdk
Added path to adb tool directory in .bash_profile to: PATH="/Users/myusername/Library/Android/sdk/platform-tools:${PATH}"
Restarted terminal for path to take effect
Ran exp path in terminal to copy path to exp
Ran adb in terminal to make sure it could find adb in platform-tools directory
Restarted Genymotion
Created and started virtual device in Genymotion
Started Expo XDE and started project
Ran Open on Android from XDE
App started on virtual device created in Genymotion (step 9)
after these steps,
on Terminal fire : npm run android
This has worked for me !

How to run NativeScript app in Windows using Visual Studio Emulator?

How to run NativeScript app in Windows using Visual Studio Emulator?
trying to get this project:
https://github.com/avatsaev/nativescript-master-detail-angular2
to run in Windows 10 64bit visual studio emulator but always android emulator is launching instead when running:
this is my adb devices:
List of devices attached
169.254.138.177:5555 device
tns livesync android --emulator --watch
also tried
tns livesync 169.254.138.177:5555 --emulator --watch
no luck!
regards
Sean
found the answer
tns run android --device 169.254.138.177:5555
and you get the device from:
adb devices
enjoy!
If the emulator is already running and visible with adb devices - you can just run tns run android. This will build and deploy on all visible devices. Same is valid for tns livesync android.

Resources