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! :)
Related
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.
The instructions for how to run a react-native project on an android device is located at: https://facebook.github.io/react-native/docs/running-on-device-android.html
After determining your USB device, the instructions state to do the following command:
echo SUBSYSTEM=="usb", ATTR{idVendor}=="22b8", MODE="0666", GROUP="plugdev" |
sudo tee /etc/udev/rules.d/51-android-usb.rules
The problem is that there is not a /etc/udev directory on my Mac. So obviously this fails.
Apparently MacOS doesn't support udev.
So how do I get this to work? If I ignore the udev part and use the command react-native run-android then it wants to run on an emulator. I experimented with --variant and just adding the values from adb devices, but no success.
--edit--
I should note that adb devices works fine, so does lsusb. The phone prompted to trust the computer, so I know that debugging is setup correctly. Just trying to figure out how to tell react-native to launch the app on the device (instead of an emulator).
I'm having huge problems with Titanium Alloy on Windows 10. I am using the Atom editor to write my apps. Whenever I execute ti build, enter the command up to 10(!!!) times until an Android device can be found.
For the Android emulator I get an error message as follows:
[Error] Failed to install apk on "emulator-5554"
[Error] Error: device not found
I tried the commands ti build -p android, ti build -p android -T emulator and ti build -p android -T emulator -C emulator-5554 --log-level info. I also tried starting the emulator manually from avd.exe. I deleted the AVD and created a new one, too
When a device (USB debugging enabled) is connected, i tried ti build -p android -T device and ti build -p android -T device -C XT1032, where XT1032 is the name of the device. I get an error message as follows:
[ERROR] Unable to find any devices
I didn't try so far if the device will be found after some more tries.
When executing the commands, I tried all 4 combinations:
emulator off, device disconnected
emulator off, device connected
emulator on, device disconnected
emulator on, device connected
I uninstalled Titanium, Android SDK, NodeJS and Java and deleted all folders of them. I removed all registry entries, too. Then I installed everything again, Titanium at last. Same problem.
I am using Java 32 bit (v8.0.1020.14), NodeJS v4.2.6 (also tried v6.3.0, but v4.2.x is recommend), Android SDK (SDK Tools v25.1.7, SDK Platform-tools 24.0.1 and SDK Build-tools 21.1.2. I also tried SDK Build-tools 24.0.1, but 21.x.x is recommend) and Titanium (SDK v6.0.0.v20160719180254, CLIv5.0.9).
I modified my environment variables as follows:
PATH:
C:\android-sdk\tools;C:\android-sdk\platform-tools;C:\android-sdk\ndk-bundle;C:\Program Files (x86)\Java\jdk<version>\bin
JAVA_HOME:
C:\Program Files (x86)\Java\jdk<version>
ANDROID_SDK_HOME:
C:\android-sdk
I had to set ANDROID_SDK_HOME and C:\android-sdk\ndk-bundle, otherwise the NDK and the AVDs wouldn't be found by ti setup check.
Here is a screenshot of ti setup check: link to image
I don't know why https://www.google.com is unreachable. Furthermore, Intel HAXM is installed. I even reinstalled it without success. The previous installation of Titanium could find it...
Thanks for your help!
TLDNR: my Titanium Alloy installation has problems finding devices. It only works from time to time without any obvious pattern
The process terminates after building the APK file. If the emulator is running, it is possible to manually install the APK. Use this command in the Command Line:
<Android SDK folder>\platform-tools\adb.exe -s emulator-5554 install -r -d <project path>\<project folder>\build\android\bin\<project name>.apk
The project name is equal to the project folder name. After installing the APK, the application can be started manually in the emulator.
Nonetheless, there are still a lot of issues when developping on Windows 10... I think this forces me to switch to a MAC.
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.
After I upgraded to Yosemite and upgraded to Xcode 7.1 I cannot start the adb server. Both of which I don't see why they would affect adb. When I type adb devices or adb start-server in the terminal I get:
cannot bind 'tcp:5037'
ADB server didn't ACK
* failed to start daemon *
error: cannot connect to daemon
There are no adb processes running that I can see in activity monitor.
I've checked with lsof -i tcp:5037 that there are running processes on port 5037.
I have the latest Android SDK.
I have checked that my .bashrc loads the correct Android SDK and adb.
I've tried to adb kill-server and then adb start-server several times, but when I run start-server I get the error message that I cannot bind tcp:5037.
I've tried deleting .android folder and unplugging/plugging in my android phone, toggling on/off USB-debugging and revoking debugging authorizations.
Android studio cannot start adb anymore as well.
I've tried restarting the computer.
I'm not running Genymotion.
None of the above worked, and I'm about to give up. I've checked every stackoverflow thread about this issue and none of the mentioned fixes have worked so far.
Success.
Oddly enough, adb worked again after I upgraded Yosemite to El Capitan (10.11).