Expo-react-native :Couldn't adb reverse: device 'adb' not found - react-native

I am using react-native-expo for mobile app development.
I use an android emulator for the app, vscode editor for development.
It started showing me this error from few days.
› Opening on Android...
Couldn't adb reverse: device 'adb' not found
› Opening exp://10.0.46.81:19000 on Device adb
Couldn't start project on Android: Error running adb: device 'adb' not found
› Press ? │ show all commands
I tried wiping the emulator, tapping on the build number in the emulator, but nothing worked out.
I've deleted the virtual devices and created new one. It worked for one time and again this process isn't working.
there isn't much about this on the internet.
need help.

Just try this. It is work for me.
make sure you already add android sdk path in setting > appearance & behavior > system settings > android SDK > android SDK location
(Common path is C:\Users(name)\AppData\Local\Android\Sdk)
create new variable name and value in Environment Variables (User Variables)
(ANDROID_HOME C:\Users(name)\AppData\Local\Android\Sdk)
add new Path in Environment Variables (User Variables)
(C:\Users(name)\AppData\Local\Android\Sdk\platform-tools)
It is work for me after I have solved it for 3 hours.
At first, I don't face the problem like this in flutter but in react-native.

The fix for me was to install the SDK Platform for the android version used by the AVD.
In my case, I installed android v9 (Pie) via the AVD Manager when setting up my AVD for the first time, and when I looked into this issue I noticed that the SDK Platform for v9 was not installed as part of that setup.
The exact steps I took are as follows:
Disclaimer: You might not need to follow these steps exactly to resolve the issue
Close all CMD and IDE programs.
Open Android Studio and navigate to AVD Manager
Click the down arrow for the target AVD and click the Edit option
Set the device to Cold boot instead of Quick boot
Open SDK Manager, and download the SDK Platform for android version used by AVD
Go back to AVD Manager, click the Cold boot now option
Open a CMD terminal as administrator, CD to project repo, and run expo start
Launch expo in AVD
DONE

I had the same problem. Emulator started working after this:
Delete caches from Android Studio
Wipe data from your emulator
Cold boot to restart
When I was solving this problem I also ended up doing these:
Check Android studio updates
Reinstalled Android studio
Check SDK updates from SDK tools: SDK Manager -> Android SDK -> SDK tools. You can see if there is a new update available on the right.

Go to Virtual Device Manager -> Select your Device -> Actions -> Click "Drop down" button and select "Cold Boot Now".
This worked for me.

For my case, I went to the avd and simply clicked "wipe data", restarted both my avd and server and it worked

By my side the problem was is In Internet Connection. I just changed the WiFi and everything working fine.

Related

“launchPackager.command” can’t be opened

Just updated my Mac to the official release of Ventura, and I cannot launch my application via react-native run-ios.
Expected behavior:
running react-native run-ios will launch an Xcode simulator and a terminal window with Metro running.
Current behavior:
Xcode simulator opens, main terminal says app was built successfully, but an error is thrown instead of the metro terminal opening:
“launchPackager.command” can’t be opened because (null) is not allowed to open documents in Terminal.
The simulator just shows a white screen and can't be interacted with.
What I've tried:
manually opening node_modules/react-native/scripts/launchPackager.command
opens Metro terminal but is not connected to the app
warn No apps connected. Sending "reload" to all React Native apps failed. Make sure your app is running in the simulator or on a phone connected via USB.
info Reloading app...
giving Terminal full disk access (no change)
This happened to me after upgrading to macOS Ventura. I happen to use iTerm as my main terminal, not the built-in Terminal.app so the following fix only applies to that scenario:
Set iTerm as the Default Handler for *.command Files
Open node_modules/react-native/scripts/ in Finder (open node_modules/react-native/scripts/)
Right-Click on launchPackager.command and click Open With then choose Other...
In your Applications directory, select iTerm and click Always Open With
After this, you might need to run npm run ios again from this terminal window. However, from now on, Metro will open in a new iTerm tab instead of trying to open the command in a new Terminal window.
For me, this was the desired behaviour and it removed this warning.
Note In future, any *.command files will now open with iTerm instead of Terminal.
I encountered the same problem as you, I installed another terminal (iTerm2), then randomly found a .command file, and in the display introduction, changed the default opening method to iTerm2enter image description here
I'm having this issue after upgrading my MacOS to Ventura 13.1.
If you don't want to use iTerm as the accepted answer suggest, the workaround I found was to look for the launchPackager.command file inside node-modules/react-native/scripts/ and open this file manually every time you run your app for the first time (specifically when the error pop-up appears). This will open the terminal with metro running already.
I know that manually processes are not the best, but I don't want to use iTerm :)
Using Intel version of apps (Webstorm, Android Studio, other IDE etc...) fixed my problems. I encountered the same issue and thanks to Intel version of Webstorm and Xcode on Rosetta I can able to pod install and other operations.
Note: I'm using Intel version of Android Studio, WebStorm. Also Xcode uses Rosetta 2. No problem detected and everything works perfect. I can able to develop React-Native & Native Android & iOS and Flutter apps without problem. Before that I was using Silicon version of WebStorm and almost no function worked.
Config: MacBook Air, macOS Ventura 13.2 on Apple M1 processor.
For Most of the case you just have to delete node_modules and install modules again (npm i). This happens when project was copied from old mac which had node_modules folder created by the old user, or if the system thinks so
This happened to me after i configured my terminal for the look and feel - but with iterm2, oh my zsh, and powerlevel10k

Couldn't start project on Android: It took too long to start the Android emulator: Pixel_2_API_30

To run my react native application, I try to create & run an emulator in android studio and get this error every time.
Couldn't start project on Android: It took too long to start the Android emulator: Pixel_2_API_30. You can try starting the emulator manually from the terminal with: C:\Users\ASUS\AppData\Local\Android\Sdk/emulator/emulator #Pixel_2_API_30
You must wipe the data. For that go to Device Manager -> Wipe Data. After that restart your Android Studio. Then after your issue may be solved. Have a look on below mentioned image to get a better understanding.
Try clear your device cache data
Android studio -> virtual device manager -> on device actions select wipe data and then cold boot every-time
This is works for me,
If you run your project on VS Code, don't let automatically Emulator start after pressing a (run on android)
What I did is, I install VS Code Android Ios Emulator Extension and, I opened the emulator first through the VS Code.
After that, you can run "npm start" and press a to run the app on the emulator!!!

AVD Manager: unable to locate adb in android studio

I'm just starting out my react track and thought of a little react-native app. Well, I installed Android Studio, the SDK and all that I needed according to https://reactnative.dev/docs/environment-setup, using the react-native CLI tab. But when I try to launch my emulator for any device on my list I get the error: AVD manager unable to locate adb. I have checked my %ANDROID_HOME% variable and it's set to the correct Sdk dir, I can use adb.exe inside the platform-tools dir with no apparent problem. But the AVD manager can't.
I even tried reinstalling Android SDK after deleting the platform-tools dir, or even installing a different version of it, but it just won't work!
Any thoughts on what is happening?
I struggled with this problem for a few days now and the number 1 suggestion I found is:
review your environment variables (such as %ANDROID_HOME%);
remove the platform-tools dir inside %ANDROID_HOME%, adb.exe is either corrupted or missing;
reinstall Android SDK and check for adb.exe inside %ANDROID_HOME%\platform-tools;
emulate a new device (you are a wizard Harry!);
Well, this didn't work for me but apparently worked for some people, especially for avast users (apparently it corrupts adb.exe 'cause it believes it to be malware).
What worked for me was:
In Android Studio go to File > Project Structure (Ctrl + Alt + Shift + S in windows);
Under Project Settings>Project>Project SDK must have a valid Android SDK selected;
emulate a new device (you are a wizard SadSack963!);

Could not install the app on the device - react native on windows 10

Everytime I try to launch a react native project I got this error
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
I reinstalled nodejs, python and jdk using choco as suggested on official docs. Every single packages is installed as well as sdk 23.0.1
I can see my virtual device if I run adb devices USB debugging is activated and it's running android 6.
I setup ANDROID_HOME path in environment variables, I'm using same sdk path as you can see in the picture. I also setup another one for JAVA_HOME and Python.
My PATH looks like this:
I just don't understand what I'm supposed to do. I'm using a surface pro 4, Windows 10. I can run projects using expo. I literally tried everything, restart computer, start cmd using admin, create new virtual devices, uninstall everything and start from scratch, it just don't work.
You have pointed out two issues; first, make sure you have an android emulator running. To do that, you run adb devices and you say you can see you device.
The other issue is with the environment. To make sure your environment is setup properly for android, go to the root of your react-native project. Open the android project using android studio.
All errors with your environment will show up, use the automatic fixes provided by android studio. Clean the project in android studio. Close studio and go back to command line, run react-native run-android
Everything should work now.
When doing react-native start it will intentionally hang at "Loading dependency graph" (its not really hanging, its just waiting to receive build/bundle signals). This is correct. You have to open a second terminal then do react-native run-android.
If you get errors, then cd android in your project folder then run ./gradlew clean, then after that do another react-native start then react-native run-android.
Solution is to delete all java JDK and reinstall v8 / change JAVA_HOME to the new path.
Also changing gradle-wrapper.propertiesfile for each project you want to run
# update gradle to latest version
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4.1-all.zip
Sometimes it dosen't compile with v4 so I have to use v3. React native is definitely confusing.
after install dan update environment JDK now I can install app on my device

emulator-5554 unauthorized for adb devices

I'm trying to get my react-native project to run on an android emulator while on a Mac operating system. It worked fine on my windows.
On my Mac, I go to terminal and type react-native run-android and I get the error message:
$ react-native run-android
Scanning 616 folders for symlinks in /Users/John/Documents/myreactnativeproject/node_modules (17ms)
Starting JS server...
Building and installing the app on the device (cd android && ./gradlew installDebug)...
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
I type adb devices and I see
List of devices attached
emulator-5554 unauthorized
I go into the settings of my android emulator, I go to Settings Build Number to tap it several times to enable Developer options. In developer options, I enabled USB debugging, disabled Verify apps over USB, and left everything else as default. I shut down my android studio and emulator, restarted it. But still, the same issues mentioned above.
What am I doing wrong?
EDIT
I just connected my android phone to my Mac. When I run adb devices, I see this result
List of devices attached
YLEDU16B18004313 device
But when I run react-native run-android, I get the same error as above. So maybe there is something wrong with my react-native set up instead?
EDIT 2
I was able to deploy the app to my android phone by adding these extra steps
chmod 755 android/gradlew
For some reason, when I type echo $ANDROID_HOME into the terminal, I get the result /Users/John/Library/Android/sdk. But if I add the echo $ANDROID_HOME line to my android/gradlew file, it echoes nothing. And when I run the react-native run-android command, the compiler complains that ANDROID_HOME is not defined. So I have to type export ANDROID_HOME=/Users/John/Library/Android/sdk again, then running the react-native run-android command works and deploys it to my phone.
However, my emulator still doesn't work. The new error message I get is that Skipping device 'emulator-5554' (emulator-5554): Device is UNAUTHORIZED,.
But at least I have a temporary solution, and to debug with my phone.
EDIT 3
I got rid of the emulator 5554 unauthorized error by going into my Android Virtual Devices and deleting the virtual device. Then I re-installed it. And now my adb devices shows emulator 5554 device. And I am not able to deploy the app to my emulator.
In my case, Create a Virtual Device with Google APIs Image, not Google Play Image worked for me.
The problem occurs the only emulator that runs on Android Pie others don't.
In Android Studio
Open an Android Virtual Device Manager.
Create a new Virtual Device.
Select any Hardware you want.
Select any System Image which the Target is "(Google APIs)" not "(Google Play)" (If you don't found. Try to look at "x86 Images" tab or "Other Images" tab)
Done!
Android emulators have by default "Usb Debugging" in settings. You just need to wipe the data of the emulator. Do the following steps. It will work :---
Close the emulator and run the command adb kill-server in the command prompt. If adb is not set in you path then you might run this command from directory where adb is present.
Click on Wipe Data option from avd Actions menu.
Now run the emulator. It should work.
create new Virtual Device, and make sure you choose Google API's.
run the new device!. this should work
In my case, following steps worked
Wipe data from avd manager
Cold boot now
I managed to authenticate the adb on a Pixel 2, Android 9.0 (Google Play), API 28, x86_64 virtual device (Intel HAXM). The problem should be related to the Extended Controls (the 3 dots bottom icon menu, when the virtual device is booted), the Google Play menu, that is checking the version of the Google Play services. When adb is not 'unauthorized', this page is displaying the correct version, and the Update button opens inside the phone the Play Store with the Play Services app, so you can update it.
The steps I took to be able to authenticate are:
Make sure the USB debugging is turned ON in Dev setting
Revoke the USB debugging authorizations
Make sure the Extended Controls > Settings > Advanced > Open GL options are set to the: 'Desktop native OpenGL' and 'Renderer maximum (up to OpenGL ES 3.1)', so the emulator interface, animations, etc, are fast!
Power off the emulator
In 'Your Virtual Devices' in Android Studio, click the down arrow in Actions > Select 'Cold Boot Now'
When the device boot, you have to be fast, the dialog to remember and accept the USB connection will show and disappear for like less than 1 second (again I guess related to some automation scripts kicking, idn).
If you manage to click the 'remember' and 'ok' checkbox and button before the dialog disappears, you are done. Else you have to Power Off and Cold Boot again.
After that, don't wipe your emulator, else you'll have to do that insane race clicking again!
I run adb kill-server and adb devices.
the device will back again.
for Emulator, the default settings is debug enabled
Creating an emulator with graphics set to "Software - GLES 2.0" worked for me (Nexus 6 image).
I was initially using a Nexus 5X image which didn't allow me to select the graphics option.
NOTE: I went through the steps mentioned in EDIT 2 and EDIT 3 by the OP before doing this.
This can happen if USB debugging is not enabled on the emulator device.
Go to the emulated device, enable the Developer options and enable USB debugging.
I had to create a new emulator with Google Api. Wiping data didn't work for me.
2022 answer
What a shame of thread: so many "answers", comments and upvotes and none worked. Nobody simply mentioned that the "adb unauthorized" is caused by the adb keys stored in ~/.android/adbkey and ~/.android/adbkey.pub After deleting and recreating them, the problem was solved.
Credit: Android Emulator Unauthorized
I got my mac system to deploy a react-native build to my physical phone by following Edit 2 in the question.
I got my mac system to deploy a react-native build to my emulator by following Edit 3 in the question.
I think the issue was generally caused by moving my project from a Windows dev area to Mac dev area. Then probably a combination of different issues happened that cause builds to fail for each situation.
Deleting emulator and creating it again helped me on Ubuntu
I solved Problem
add ANDROID_SDK_HOME to environment variable
ANDROID_SDK_HOME = D:\sdk
and unplug device
and use new cmd