error on running android emulator: spawn adb ENOENT - reactjs

I created a new react native app by using the expo cli.
iOS Xcode Emulator is working fine but getting below error for android emulator
Error: spawn adb ENOENT
I tried to uninstall and install back expo-cli. Tried to delete the emulator and create a new one. None of them is working.

I was in your same situation wherein I’d just installed expo and tried to run the app in an emulator on my Mac.
Apparently the problem was that ANDROID_HOME and adb weren’t set in my $PATH.
I solved it by referring to Option 3 (I already had android studio installed) of the top voted answer here. 

In case you want to know what I did, I use ohmyzsh by default so I did the following:
nano .zshrc
Add these two lines in the .zshrc file.
export ANDROID_HOME=/Users/$USER/Library/Android/sdk
export PATH=${PATH}:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools
Then run this in your terminal:
source ~/.zshrc
Restart your terminal and now everything works!

Related

Getting /bin/sh: adb: command not found issue when running app on android in react native

I am getting /bin/sh: adb: command not found issue when running app on android using react native. The app icon displays but app is not opening here is attached screenshot.
Install adb, from here
For more info here
Then set PATH environment variable in .bashrc / .bash_profile / .zshrc(whichever you have).
On a new terminal try command adb. It should be accessible.
In the terminal that you put "npx react-native run-android", set environment variables again like:
source $HOME/.zprofile (if you use zsh)
source $HOME/.bash_profile (if you use bash)

React native run stays in IDLE state

This is my first time setting up react native on Ubuntu 18.04 LTS. I have done the setup and I was trying to run the app on the device using the react-native run-android command.
Here is the output what I get in terminal,
ron#lenovo:~/react/app$ react-native run-android
Scanning folders for symlinks in /home/ron/react/app/node_modules (9ms)
JS server already running.
Building and installing the app on the device (cd android && ./gradlew installDebug)...
Starting a Gradle Daemon, 1 busy Daemon could not be reused, use --status for details
NDK is missing a "platforms" directory.
If you are using NDK, verify the ndk.dir is set to a valid NDK directory. It is currently set to /home/ron/Android/Sdk/ndk-bundle.
If you are not using NDK, unset the NDK variable from ANDROID_NDK_HOME or local.properties to remove this warning.
File /home/ron/.android/repositories.cfg could not be loaded.
Checking the license for package Android SDK Build-Tools 26.0.3 in /home/ron/Android/Sdk/licenses
License for package Android SDK Build-Tools 26.0.3 accepted.
Preparing "Install Android SDK Build-Tools 26.0.3 (revision: 26.0.3)".
<=============> 100% CONFIGURING
> IDLE
It stays in this IDLE position forever. What is the fix or this issue?
The solution is to install Android SDK rev. 26.0.3. Your can install it from Android Studio's SDK Manager menu in File > Settings. Hope this helps.
I got the same error today. The solution is to create a file named local.properties and write in it this line:
sdk.dir=[the position of android sdk]
example:
sdk.dir=N\:\\Users\\andy\\AppData\\Local\\Android\\Sdk
you can get the sdk android via android studio: Android Studio - How to Change Android SDK Path
hope this will help you and other people out there who just begin learning react native.

error: no devices/emulators found, Run React Native on Genymotion

iam using genymotion emulator to run react native on mac,
react-native-cli: 2.0.1
react-native: 0.53.0
node:v8.9.4
while i running react-native run-android i got error like this
...
.....
Installing APK 'app-debug.apk' on 'GNexus5623 - 6.0' for app:debug
11:17:39 E/DeviceMonitor: Adb connection Error:EOF
11:17:39 E/DeviceMonitor: Connection attempts: 1
Installed on 1 device.
BUILD SUCCESSFUL
Total time: 14.691 secs
This build could be faster, please consider using the Gradle Daemon: https://docs.gradle.org/2.14.1/userguide/gradle_daemon.html
Starting the app (/Users/yan/Library/Android/sdk/platform-tools/adb shell am start -n com.vero/com.vero.MainActivity...
error: no devices/emulators found
does anyone give me solution, thanks
this worked for me (For debian based systems only), make sure you have configured genymotion to use your android Sdk by:
Open Genymotion
Click on the settings icon
go to ADB tab
Click on use Custom Sdk tools.
navigate to the folder you downloaded
and then add this to your .bashrc
export PATH=/home/{username}/Android/Sdk/tools:/home/{username}/Android/Sdk/platform-tools:$PATH

can not install app on react native

I am trying to install an app with react native cli but get the
ERROR: JAVA_HOME is not set and no 'java' command could be found in
your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation. Could not install the app on the
device, read the error above for details. Make sure you have an
Android emulator running or a device connected and have set up your
Android development environment:
https://facebook.github.io/react-native/docs/android-setup.html
error...
And frankly this is sooo ofrustrating... Never had an issue with ionic or cordova nor android studio but infortunally, I need some native functions for my app...
Here is a background, at first the app was installing, I even was able to run hot reload on it then out of nowhere, without any change on the computer, I get this message whenever I try :react-native run-android".... I followed exactly what's on facebook github page but got this error... So i tried running a simple app on android studio and it worked...
Can someone have solution and also why this is happening out of nowhere?
Oh, I forgot right before I got this error, for some reason, I had to reinstall npm because nodeJs was not recognizing the npm command anymore
Ps : I even uninstall then reinstall android studio, uninstalled react-native-cli and reinstalling it, uninstalled react-native-create-project, reinstalled npm.
Check like this maybe this is the issue I guess:
1.Open the App that u have created using create-react-native-app or react-native init appName in android studio
It will be something like: appName>android>local properties(SDK location)
2.If u use windows pc/laptop then go to my computer right click for properties>advanced system settings click on that and find the environmental variables
and check if they are matching
Well, I got tired of it since none of the solutions on the web worked, I just wiped out my computer, reinstalled windows, got rid of all the non needed programs, reinstalled android SDK, java, react and... Still got this error... So I set JAVA_HOME (thanks youtube) and now it is working.

React-Native on windows 8.1. throwing react-native command not found

I'm having issues setting up React-Native on windows 8.1. I have installed react native with the npm install -g react-native-cli yet when I execute react-native init Myproject I get react-native: command not found. I'm using an elevated Powershell so this is rather frustrating. Need your help
You need to add the global npm directory to your path, which the Windows installer for current NodeJS Long Term Support release (6.10.x) should have done automatically. I'd recommend uninstalling nodejs, and then reinstalling latest LTS release. That should add the path for you automatically, I just verified as such in a Windows 7 virtual machine.
If that didn't add the path for some reason, you can do it manually from the System control panel.

Resources