Android issues with React-Native and Mac Apple M1 (adb & launchPackager) - android

I just got a new iMac with the M1 chip, so i reinstall all my project and i have 2 issue for Android :
Everytime i try to run my project i have this :
imac#iMac-de-Developpement XXXAppMobile % npm run XXX
> XXXAppMobile#0.0.1 XXX /Users/imac/Documents/Travail/XXXAppMobile
> npx react-native run-android --variant=XXXDebug --appId=com.XXXappmobile
info Running jetifier to migrate libraries to AndroidX. You can disable it using "--no-jetifier" flag.
Jetifier found 1273 file(s) to forward-jetify. Using 8 workers...
info Starting JS server...
/platform-tools/adb: No such file or directory
info Launching emulator...
error Failed to launch emulator. Reason: No emulators found as an output of `emulator -list-avds`
Here is my .zprofile file :
eval $(/opt/homebrew/bin/brew shellenv)
export ANDROID_HOME=$HOME/Library/Android/sdk
export PATH=$PATH:$ANDROID_HOME/emulator
export PATH=$PATH:$ANDROID_HOME/tools
export PATH=$PATH:$ANDROID_HOME/tools/bin
export PATH=$PATH:$ANDROID_HOME/platform-tools
export PATH=/opt/homebrew/opt/ruby/bin:/opt/homebrew/lib/ruby/gems/3.0.0/bin:$PATH
export LDFLAGS="-L/opt/homebrew/opt/ruby/lib"
export CPPFLAGS="-I/opt/homebrew/opt/ruby/include"
I've already tried to to source ~/.zprofile nothing change, but what change is if i enter this in the terminal : export ANDROID_HOME=$HOME/Library/Android/sdk.
But i have to do this everytime...
So its like my .zprofile file is not readed because this is litteraly the second line of this file !
Second issue is this :
I've tried to chmod 777 node_modules/react-native/scripts/launchPackager.command and to open from the finder but no change, i have to do npm run start before build my app... its really annoying.
If someone have a solution for my problems 🙏🏼
Thank you.

Related

Unable to load script make sure you are either running a metro server react native solution [duplicate]

I am trying to get React-Native to work with Android V4.2.2 (Genymotion) but I am unable to test the app on the Emulator. When I ran react-native run-android, I get this error Could not run adb reverse: spawnSync
Here is a log
JS server already running.
Running ~/Library/Android/sdk/platform-tools/adb reverse tcp:8081 tcp:8081
Could not run adb reverse: spawnSync ~/Library/Android/sdk/platform-tools/adb ENOENT
Building and installing the app on the device (cd android && ./gradlew installDebug...
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring project ':app'.
> The SDK directory '~/Library/Android/sdk' does not exist.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 3.785 secs
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
NOTE: In the log it saids SDK directory does not exist, I have double check that I do have the SDK installed in that directory.
I found my android emulator when executing adb devices
List of devices attached
192.168.56.101:5555 device
I have tried the following steps from Stack Overflow post, but still no luck
https://stackoverflow.com/a/38536290/4540216
I got the same issue. I updated my ANDROID_HOME env variable again it worked for me.
Follow this React-native android-setup documentation
ex:
export ANDROID_HOME=~/Library/Android/sdk
Windows:
set ANDROID_HOME=c:/Users/whoever/AppData/Local/Android/Sdk
macOS Mojave and earlier or bash users:
1 - Open your bash profile:
open .bash_profile
Add this to your bash_profile:
export ANDROID_SDK=/Users/<your_computer_name>/Library/Android/sdk
export PATH=/Users/<your_computer_name>/Library/Android/sdk/platform-tools:$PATH
Save and close
Compile your changes
source ~/.bash_profile
For macOS Catalina and zsh users:
Starting with macOS Catalina, your Mac uses zsh as the default login shell and interactive shell. You can make zsh the default in earlier versions of macOS as well.
On your Mac:
Open your .zshrc file:
open ~/.zshrc
If .zshrc file not exist, you need to create one using touch & open.
touch ~/.zshrc
Add this to your .zshrc file
export ANDROID_SDK=/Users/<your_computer_name>/Library/Android/sdk
export PATH=/Users/<your_computer_name>/Library/Android/sdk/platform-tools:$PATH
Save and close
Compile your changes
source ~/.zshrc
Edit: Updated answer for macOS Catalina and zsh users.
Starting with macOS Catalina, your Mac uses zsh as the default login shell and interactive shell. You can make zsh the default in earlier versions of macOS as well.
More details on zsh from Apple
So on your Mac:
1 - Open your .zshrc file:
open ~/.zshrc
2 - if .zshrc file doesn't exist, you need to create one & open again(Step 1)
touch ~/.zshrc
3 - Add this to your .zshrc file(Add JAVA_HOME to use Android Studio Embedded JDK)
export JAVA_HOME=/Applications/Android\ Studio.app/Contents/jre/Contents/Home
export ANDROID_HOME=/Users/<your_computer_name_here>/Library/Android/sdk
export PATH=$ANDROID_HOME/emulator:$PATH
export PATH=$ANDROID_HOME/platform-tools:$PATH
export PATH=$ANDROID_HOME/tools:$PATH
export PATH=$ANDROID_HOME/tools/bin:$PATH
4 - Save and close
5 - Compile your changes
source ~/.zshrc
& make sure to restart your terminal.
I also got the same issue. And I updated my ANDROID_HOME env variable again in same cmd and it was worked fine.
> export ANDROID_HOME=~/Android/Sdk
> export PATH=$PATH:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools
good luck
this was my solutions
operating system: Linux mint
sudo apt-get install android-tools-adb
This answer is for MacOs Catalina or above user or zsh users as your Mac now uses zsh as the default login shell and interactive shell.
This is related to path issues.
If you follow along with the docs of React Native Setting up the development environment guide. Then do the following.
Open ~/.zshrc using editor. In my case I use vim
vim ~/.zshrc
Add the following line for the path.
export ANDROID_HOME="/Users/<yourcomputername>/Library/Android/sdk"
export PATH=$ANDROID_HOME/emulator:$PATH
export PATH=$ANDROID_HOME/tools:$PATH
export PATH=$ANDROID_HOME/tools/bin:$PATH
export PATH=$ANDROID_HOME/platform-tools:$PATH
Make sure to add the above line correctly else it will give you a weird error.
Save the changes and close the editor.
Finally, now compile your changes
source ~/.zshrc
I get this working in my case. I hope this helps you.
I solved this error with installing adb
On Linux
sudo apt-get install android-tools-adb
First I have setup the path in .bash_profile like this
export PATH="~/Library/Android/sdk/platform-tools":$PATH
export ANDROID_HOME="~/Library/Android/sdk/platform-tools"
But it does not resolve my problem.
For me by adding following npm script in package.json under script tag worked like charm on Mac.
"android-dev": "adb reverse tcp:8081 tcp:8081 && react-native run-android"
Then I am simply running npm run android-dev and it's all set. Make sure that in your app setting Live reload is enabled already, in this way I can worked on development server on my mobile and see the coding changes immediately in app.
I was on Linux and in my case the ANDROID_HOME env variable was already added to the .zshrc but the path was incorrect, correcting the path fixed it.
export ANDROID_SDK_ROOT=$HOME/Android/Sdk
export ANDROID_HOME=$HOME/Android/Sdk
export PATH=$PATH:$ANDROID_HOME/emulator:$PATH
export PATH=$PATH:$ANDROID_HOME/tools:$PATH
export PATH=$PATH:$ANDROID_HOME/tools/bin:$PATH
export PATH=$PATH:$ANDROID_HOME/platform-tools:$PATH
add these in the ~/.zshrc file and reload your terminal.
If none of the solution works. Try running
source ~/.bash_profile&&react-native run-android
Update this in the package.json file under scripts for android as
"android": "source ~/.bash_profile&&react-native run-android"
For MacOS version Catalina and above:
"android": "source ~/.zshrc&&react-native run-android"
This worked for me,
On Linux
sudo apt-get install android-tools-adb
For Mac only
If the accepted answer doesn't work for you then check if you have "adb" installed on your system. If not, install adb using homebrew.
touch ~/.zshrc
open ~/.zshrc
add
export ANDROID_SDK=/Users/<your_computer_name>/Library/Android/sdk
export PATH=/Users/<your_computer_name>/Library/Android/sdk/platform-tools:$PATH
save
source ~/.zshrc
run android
In my situation, I'm on Pop OS(Ubuntu) and I have android-studio installed, so I just
ln -s ~/Android/Sdk/platform-tools/adb /usr/bin/adb

Trying to build react native app for Android on Mac M1 - Error: No emulators found as an output of `emulator -list-avds`

I have installed Android Studio on my mac M1
I have added a virtual device in Android Studio using Device Manager
The app builds fine from inside Android Studio......however when I run npx react-native run-android from command line in VSCode, I get the error No emulators found as an output of emulator -list-avds
However when I navigate to emulator folder using cd ~/Library/Android/sdk/emulator and run command ./emulator -avd {AVD_NAME}, the emulator starts fine.....however even with the emulator running, the command npx react-native run-android still gives the error No emulators found as an output of emulator -list-avds
UPDATE 04/26 - I followed instructions from #qqNade, however I am still getting same error...see screenshot below:
Just noticed from the screenshot above, the error
/bin/sh: adb: command not found
..also, when I run echo $PATH in terminal, I get the following response:
/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/Apple/usr/bin
I dont see any reference to android in there, so I assume thats not a good thing
UPDATE 04/26 #2
I added a ~/.zshrc file and populated it as per below:
export ANDROID_HOME="$HOME/Library/Android/sdk"
export
PATH="$ANDROID_HOME/tools:$ANDROID_HOME/tools/bin:$ANDROID_HOME/platform-tools:$PATH"
..that solved the /bin/sh: adb: command not found error, but now I have a new one:
error Failed to install the app. Make sure you have the Android development environment set up: https://reactnative.dev/docs/environment-setup.
Error: spawn ./gradlew EACCES
at Process.ChildProcess._handle.onexit (node:internal/child_process:283:19)
at onErrorNT (node:internal/child_process:476:16)
at processTicksAndRejections (node:internal/process/task_queues:83:21)
....at least its launching the emulator now
UPDATE 04/26 #3
A number of SO posts told me to run the following command from android folder (and then clean)
chmod +x gradlew;
...now Im getting a different error:
Error: Command failed: ./gradlew app:installDebug -PreactNativeDevServerPort=8081
./gradlew: line 188: syntax error: unexpected end of file
Im wondering if this has anything to do with fact that I created the app originally on Windows.....and this is the first time Im trying to build on Mac?
I checked gradlew file in VSCode and its showing as LF (not CRLF) which as I understand it is correct when building for Mac
I also faced such a problem, to solve it you need to open a command prompt and enter
nano ~/.zsh_profile
after which you need to add this to the file and save
export ANDROID_HOME=$HOME/Library/Android/sdk
export PATH=$PATH:$ANDROID_HOME/emulator
export PATH=$PATH:$ANDROID_HOME/tools
export PATH=$PATH:$ANDROID_HOME/tools/bin
export PATH=$PATH:$ANDROID_HOME/platform-tools
then enter on the command line
source $HOME/.zsh_profile
I want to help you.
You're in the home directory (you can go there with cd $HOME or cd ~)
export ANDROID_HOME=$HOME/Library/Android/sdk
export PATH=$PATH:$ANDROID_HOME/emulator
export PATH=$PATH:$ANDROID_HOME/tools
export PATH=$PATH:$ANDROID_HOME/tools/bin
export PATH=$PATH:$ANDROID_HOME/platform-tools
source ~/.bash_profile (or source ~/.zshrc, take a look at my note at the end please)
After that, when you execute command vi .bash_profile (or vi .zshrc), you should see something like that
At this point, you can try to execute emulator -list-avds command again
And yes, echo $PATH should show you entries related with Android like ~/Library/Android/sdk/platform-tools
echo $ANDROID_HOME as well
If still not working, I would try to navigate to android folder and run the commands below one more time
chmod +x gradlew
./gradlew clean
react-native run-android
NOTE: Please be sure which shell your mac is using with the command below.
echo $0
Further reading
setting up development environment
I have used homebrew for setting up
echo $PATH
/bin:/usr/bin:/usr/local/bin:/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/Apple/usr/bin:/Users/userName/Library/Android/sdk/emulator:/Users/userName/Library/Android/sdk/platform-tools
when we get this error,
error Failed to install the app. Make sure you have the Android development environment set up: https://reactnative.dev/docs/environment-setup.
Error: spawn ./gradlew EACCES
at Process.ChildProcess._handle.onexit (node:internal/child_process:283:19)
at onErrorNT (node:internal/child_process:476:16)
at processTicksAndRejections (node:internal/process/task_queues:83:21)
try running this command and it will update the gradlew file with access permission, this is for M1 chip machine only
cd android
chmod +x gradlew
This solved my issue

Problem while installing a React Native App on physical phone

When I run "yarn android", to install the app on the phone I get this error:
error Failed to install the app. Make sure you have the Android development environment set up: https://reactnative.dev/docs/environment-setup. Run CLI with --verbose flag for more details.
Error: Command failed: ./gradlew app:installDebug -PreactNativeDevServerPort=8081
Unable to install /home/dapedo/Projects/CJR/test/AwesomeProject/android/app/build/outputs/apk/debug/app-debug.apk
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
I already checked the system PATH and all seems to be correct:
export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64
export ANDROID_HOME=$HOME/Android/Sdk
export PATH=$PATH:$ANDROID_HOME/emulator
export PATH=$PATH:$ANDROID_HOME/tools
export PATH=$PATH:$ANDROID_HOME/tools/bin
export PATH=$PATH:$ANDROID_HOME/platform-tools
export PATH=$PATH:~/android-studio/bin
I tried to run it on Android Studio, and it install the app, but I get some error, probably because there's no connection. When I run "yarn android" with the app open, I get a blank page instead of the errors, but the same error appears on the terminal.
Run the following command
chmod 755 android/gradlew
inside your app root folder
then run
react-native run-android
I went to the Android SDK cofigs, and disabled all the unused things, than initialized a new React Native project, that solved my problem.

Could not run adb reverse: spawnSync Typo in file location? [duplicate]

I am trying to get React-Native to work with Android V4.2.2 (Genymotion) but I am unable to test the app on the Emulator. When I ran react-native run-android, I get this error Could not run adb reverse: spawnSync
Here is a log
JS server already running.
Running ~/Library/Android/sdk/platform-tools/adb reverse tcp:8081 tcp:8081
Could not run adb reverse: spawnSync ~/Library/Android/sdk/platform-tools/adb ENOENT
Building and installing the app on the device (cd android && ./gradlew installDebug...
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring project ':app'.
> The SDK directory '~/Library/Android/sdk' does not exist.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 3.785 secs
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
NOTE: In the log it saids SDK directory does not exist, I have double check that I do have the SDK installed in that directory.
I found my android emulator when executing adb devices
List of devices attached
192.168.56.101:5555 device
I have tried the following steps from Stack Overflow post, but still no luck
https://stackoverflow.com/a/38536290/4540216
I got the same issue. I updated my ANDROID_HOME env variable again it worked for me.
Follow this React-native android-setup documentation
ex:
export ANDROID_HOME=~/Library/Android/sdk
Windows:
set ANDROID_HOME=c:/Users/whoever/AppData/Local/Android/Sdk
macOS Mojave and earlier or bash users:
1 - Open your bash profile:
open .bash_profile
Add this to your bash_profile:
export ANDROID_SDK=/Users/<your_computer_name>/Library/Android/sdk
export PATH=/Users/<your_computer_name>/Library/Android/sdk/platform-tools:$PATH
Save and close
Compile your changes
source ~/.bash_profile
For macOS Catalina and zsh users:
Starting with macOS Catalina, your Mac uses zsh as the default login shell and interactive shell. You can make zsh the default in earlier versions of macOS as well.
On your Mac:
Open your .zshrc file:
open ~/.zshrc
If .zshrc file not exist, you need to create one using touch & open.
touch ~/.zshrc
Add this to your .zshrc file
export ANDROID_SDK=/Users/<your_computer_name>/Library/Android/sdk
export PATH=/Users/<your_computer_name>/Library/Android/sdk/platform-tools:$PATH
Save and close
Compile your changes
source ~/.zshrc
Edit: Updated answer for macOS Catalina and zsh users.
Starting with macOS Catalina, your Mac uses zsh as the default login shell and interactive shell. You can make zsh the default in earlier versions of macOS as well.
More details on zsh from Apple
So on your Mac:
1 - Open your .zshrc file:
open ~/.zshrc
2 - if .zshrc file doesn't exist, you need to create one & open again(Step 1)
touch ~/.zshrc
3 - Add this to your .zshrc file(Add JAVA_HOME to use Android Studio Embedded JDK)
export JAVA_HOME=/Applications/Android\ Studio.app/Contents/jre/Contents/Home
export ANDROID_HOME=/Users/<your_computer_name_here>/Library/Android/sdk
export PATH=$ANDROID_HOME/emulator:$PATH
export PATH=$ANDROID_HOME/platform-tools:$PATH
export PATH=$ANDROID_HOME/tools:$PATH
export PATH=$ANDROID_HOME/tools/bin:$PATH
4 - Save and close
5 - Compile your changes
source ~/.zshrc
& make sure to restart your terminal.
I also got the same issue. And I updated my ANDROID_HOME env variable again in same cmd and it was worked fine.
> export ANDROID_HOME=~/Android/Sdk
> export PATH=$PATH:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools
good luck
this was my solutions
operating system: Linux mint
sudo apt-get install android-tools-adb
This answer is for MacOs Catalina or above user or zsh users as your Mac now uses zsh as the default login shell and interactive shell.
This is related to path issues.
If you follow along with the docs of React Native Setting up the development environment guide. Then do the following.
Open ~/.zshrc using editor. In my case I use vim
vim ~/.zshrc
Add the following line for the path.
export ANDROID_HOME="/Users/<yourcomputername>/Library/Android/sdk"
export PATH=$ANDROID_HOME/emulator:$PATH
export PATH=$ANDROID_HOME/tools:$PATH
export PATH=$ANDROID_HOME/tools/bin:$PATH
export PATH=$ANDROID_HOME/platform-tools:$PATH
Make sure to add the above line correctly else it will give you a weird error.
Save the changes and close the editor.
Finally, now compile your changes
source ~/.zshrc
I get this working in my case. I hope this helps you.
I solved this error with installing adb
On Linux
sudo apt-get install android-tools-adb
First I have setup the path in .bash_profile like this
export PATH="~/Library/Android/sdk/platform-tools":$PATH
export ANDROID_HOME="~/Library/Android/sdk/platform-tools"
But it does not resolve my problem.
For me by adding following npm script in package.json under script tag worked like charm on Mac.
"android-dev": "adb reverse tcp:8081 tcp:8081 && react-native run-android"
Then I am simply running npm run android-dev and it's all set. Make sure that in your app setting Live reload is enabled already, in this way I can worked on development server on my mobile and see the coding changes immediately in app.
I was on Linux and in my case the ANDROID_HOME env variable was already added to the .zshrc but the path was incorrect, correcting the path fixed it.
export ANDROID_SDK_ROOT=$HOME/Android/Sdk
export ANDROID_HOME=$HOME/Android/Sdk
export PATH=$PATH:$ANDROID_HOME/emulator:$PATH
export PATH=$PATH:$ANDROID_HOME/tools:$PATH
export PATH=$PATH:$ANDROID_HOME/tools/bin:$PATH
export PATH=$PATH:$ANDROID_HOME/platform-tools:$PATH
add these in the ~/.zshrc file and reload your terminal.
If none of the solution works. Try running
source ~/.bash_profile&&react-native run-android
Update this in the package.json file under scripts for android as
"android": "source ~/.bash_profile&&react-native run-android"
For MacOS version Catalina and above:
"android": "source ~/.zshrc&&react-native run-android"
This worked for me,
On Linux
sudo apt-get install android-tools-adb
For Mac only
If the accepted answer doesn't work for you then check if you have "adb" installed on your system. If not, install adb using homebrew.
touch ~/.zshrc
open ~/.zshrc
add
export ANDROID_SDK=/Users/<your_computer_name>/Library/Android/sdk
export PATH=/Users/<your_computer_name>/Library/Android/sdk/platform-tools:$PATH
save
source ~/.zshrc
run android
In my situation, I'm on Pop OS(Ubuntu) and I have android-studio installed, so I just
ln -s ~/Android/Sdk/platform-tools/adb /usr/bin/adb

React Native adb reverse ENOENT

I am trying to get React-Native to work with Android V4.2.2 (Genymotion) but I am unable to test the app on the Emulator. When I ran react-native run-android, I get this error Could not run adb reverse: spawnSync
Here is a log
JS server already running.
Running ~/Library/Android/sdk/platform-tools/adb reverse tcp:8081 tcp:8081
Could not run adb reverse: spawnSync ~/Library/Android/sdk/platform-tools/adb ENOENT
Building and installing the app on the device (cd android && ./gradlew installDebug...
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring project ':app'.
> The SDK directory '~/Library/Android/sdk' does not exist.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 3.785 secs
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
NOTE: In the log it saids SDK directory does not exist, I have double check that I do have the SDK installed in that directory.
I found my android emulator when executing adb devices
List of devices attached
192.168.56.101:5555 device
I have tried the following steps from Stack Overflow post, but still no luck
https://stackoverflow.com/a/38536290/4540216
I got the same issue. I updated my ANDROID_HOME env variable again it worked for me.
Follow this React-native android-setup documentation
ex:
export ANDROID_HOME=~/Library/Android/sdk
Windows:
set ANDROID_HOME=c:/Users/whoever/AppData/Local/Android/Sdk
macOS Mojave and earlier or bash users:
1 - Open your bash profile:
open .bash_profile
Add this to your bash_profile:
export ANDROID_SDK=/Users/<your_computer_name>/Library/Android/sdk
export PATH=/Users/<your_computer_name>/Library/Android/sdk/platform-tools:$PATH
Save and close
Compile your changes
source ~/.bash_profile
For macOS Catalina and zsh users:
Starting with macOS Catalina, your Mac uses zsh as the default login shell and interactive shell. You can make zsh the default in earlier versions of macOS as well.
On your Mac:
Open your .zshrc file:
open ~/.zshrc
If .zshrc file not exist, you need to create one using touch & open.
touch ~/.zshrc
Add this to your .zshrc file
export ANDROID_SDK=/Users/<your_computer_name>/Library/Android/sdk
export PATH=/Users/<your_computer_name>/Library/Android/sdk/platform-tools:$PATH
Save and close
Compile your changes
source ~/.zshrc
Edit: Updated answer for macOS Catalina and zsh users.
Starting with macOS Catalina, your Mac uses zsh as the default login shell and interactive shell. You can make zsh the default in earlier versions of macOS as well.
More details on zsh from Apple
So on your Mac:
1 - Open your .zshrc file:
open ~/.zshrc
2 - if .zshrc file doesn't exist, you need to create one & open again(Step 1)
touch ~/.zshrc
3 - Add this to your .zshrc file(Add JAVA_HOME to use Android Studio Embedded JDK)
export JAVA_HOME=/Applications/Android\ Studio.app/Contents/jre/Contents/Home
export ANDROID_HOME=/Users/<your_computer_name_here>/Library/Android/sdk
export PATH=$ANDROID_HOME/emulator:$PATH
export PATH=$ANDROID_HOME/platform-tools:$PATH
export PATH=$ANDROID_HOME/tools:$PATH
export PATH=$ANDROID_HOME/tools/bin:$PATH
4 - Save and close
5 - Compile your changes
source ~/.zshrc
& make sure to restart your terminal.
I also got the same issue. And I updated my ANDROID_HOME env variable again in same cmd and it was worked fine.
> export ANDROID_HOME=~/Android/Sdk
> export PATH=$PATH:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools
good luck
this was my solutions
operating system: Linux mint
sudo apt-get install android-tools-adb
This answer is for MacOs Catalina or above user or zsh users as your Mac now uses zsh as the default login shell and interactive shell.
This is related to path issues.
If you follow along with the docs of React Native Setting up the development environment guide. Then do the following.
Open ~/.zshrc using editor. In my case I use vim
vim ~/.zshrc
Add the following line for the path.
export ANDROID_HOME="/Users/<yourcomputername>/Library/Android/sdk"
export PATH=$ANDROID_HOME/emulator:$PATH
export PATH=$ANDROID_HOME/tools:$PATH
export PATH=$ANDROID_HOME/tools/bin:$PATH
export PATH=$ANDROID_HOME/platform-tools:$PATH
Make sure to add the above line correctly else it will give you a weird error.
Save the changes and close the editor.
Finally, now compile your changes
source ~/.zshrc
I get this working in my case. I hope this helps you.
I solved this error with installing adb
On Linux
sudo apt-get install android-tools-adb
First I have setup the path in .bash_profile like this
export PATH="~/Library/Android/sdk/platform-tools":$PATH
export ANDROID_HOME="~/Library/Android/sdk/platform-tools"
But it does not resolve my problem.
For me by adding following npm script in package.json under script tag worked like charm on Mac.
"android-dev": "adb reverse tcp:8081 tcp:8081 && react-native run-android"
Then I am simply running npm run android-dev and it's all set. Make sure that in your app setting Live reload is enabled already, in this way I can worked on development server on my mobile and see the coding changes immediately in app.
I was on Linux and in my case the ANDROID_HOME env variable was already added to the .zshrc but the path was incorrect, correcting the path fixed it.
export ANDROID_SDK_ROOT=$HOME/Android/Sdk
export ANDROID_HOME=$HOME/Android/Sdk
export PATH=$PATH:$ANDROID_HOME/emulator:$PATH
export PATH=$PATH:$ANDROID_HOME/tools:$PATH
export PATH=$PATH:$ANDROID_HOME/tools/bin:$PATH
export PATH=$PATH:$ANDROID_HOME/platform-tools:$PATH
add these in the ~/.zshrc file and reload your terminal.
If none of the solution works. Try running
source ~/.bash_profile&&react-native run-android
Update this in the package.json file under scripts for android as
"android": "source ~/.bash_profile&&react-native run-android"
For MacOS version Catalina and above:
"android": "source ~/.zshrc&&react-native run-android"
This worked for me,
On Linux
sudo apt-get install android-tools-adb
For Mac only
If the accepted answer doesn't work for you then check if you have "adb" installed on your system. If not, install adb using homebrew.
touch ~/.zshrc
open ~/.zshrc
add
export ANDROID_SDK=/Users/<your_computer_name>/Library/Android/sdk
export PATH=/Users/<your_computer_name>/Library/Android/sdk/platform-tools:$PATH
save
source ~/.zshrc
run android
In my situation, I'm on Pop OS(Ubuntu) and I have android-studio installed, so I just
ln -s ~/Android/Sdk/platform-tools/adb /usr/bin/adb

Categories

Resources