When i run a react native simple app using command.react-native run-android.Then i got an error "could not connect to a development server, although my packager is also run.
There is a few things you can try to solve this.
From the React Native official docs (https://facebook.github.io/react-native/docs/troubleshooting) you could try to "terminate the process on port 8081" by running:
$ sudo lsof -i :8081
$ kill -9 <PID>
You will run the second command on all PIDs that are using port 8081 (this will terminate your emulator too).
Then, restart the emulator and in one terminal, run:
$ npm start
and on a second terminal:
$ react-native run-android
Hope this can help!
Starting with Android 9.0 (API level 28), cleartext support is disabled by default.
https://stackoverflow.com/a/53158627/1490685
Related
When I run a command like react-native run-ios or react-native start, it launches a new terminal window with the react native compiling process running/watching inside of the new terminal window.
How can I watch for this new process to start? Or find it among running terminal processes? Find the pid, etc.
My task is specific and obscure, but this is more or less exactly what I need to do. Can anyone help?
Checking which PID is used for the port of your react native application should suffice. The standard port for the react-native-cli when running react-native run-ios or react-native start is 8081. For expo it is 19000.
For specifying a custom port (e.g. 9988) use
react-native start --port 9988
When your react native application is running, then you can check the corresponding PID in usage for that port (sudo might be needed at the beginning of the command)
lsof -i -P | grep LISTEN | grep 8081
node 38273 [USER] 31u IPv6 0x2207bcb724ddd40d 0t0 TCP *:8081 (LISTEN)
In this example, the corresponding PID is 38273
screenshot of terminal
I'm using MacBook Air M1.
To make react-native work on a physical device with expo application, I wrote these codes:
npm install -g expo-cli
npx expo-cli init cars
cd cars
npm start
But it doesn't work, I'm looking forward your replies thank you.
Try to run expo start and make sure that port 8081 not used by any other server. Because in given screenshot it looks your port 8081 is already been used and on top of that you trying to run expo project thats why always failing.
I think your previous process is still running, try to stop those process and then start expo server again
Do this to stop the process:
Run this command for getting PID of the process running in your port 8081
lsof -i tcp:8081
Note the PID from the table which is shown after that command
Run this command to kill your process kill -9 {PID}.
kill -9 3421
You have to add your PID in place of 3421 that I used.
I Hope that it helps..
I am new to ReactNative. I have installed react-native in my Ubuntu(18.04). I am trying to run the basic app after installation using CLI.
I am trying to make the build in android using sudo react-native run-android after successful build server closed automatically. It means that I have to run the command every time after making change.
Development Server closed automatically.
Please find the screenshot.
Development Server Closed
This error is coming because some process is already running on 8081 port. Stop that process and then run your command, it will run your code. For this first list all the process which are using this port by typing
$ adb reconnect
This is not necessary in most cases, but just in case, let's reset your connection with your mobile and restart adb server. Finally:
$ adb reverse tcp:8081 tcp:8081
Then run this command
lsof -i :8081
You will get a Process id which is using port 8081 Now kill the process
$ sudo kill -9 <PID>
Then run the project
react-native run-android
I faced same issues.
I solved the issues by changing node version from 13.3.0 to node version 10.18.0.
I try build react-native run-android on windows this bug appear
then i do follow the answer on this github issue try Command chmod 755 android/gradlew on root folder but chmod' is not recognized as an internal or external command,
operable program or batch file. i think this answer for linux . Some body help me . Thanks for reading my question
The error states that you neither have any android device connected nor do you have emulator running. Follow this guide for android setup.
If you already have android setup and running emulator, try restarting it and run following commands:
Try running following commands:
cd android && ./gradlew clean
cd .. && react-native run-android
From your question seems like you are not started your emulator or device connected.
Follow this steps:-
1.Open your CMD/Terminal from your system
write this command cd "YOUR PATH TO ANDROID SDK"
for example, mine looks like::-
cd /Users/trainee02/Library/Android/sdk/platform-tools
and then hit enter.
3.after enter in directory write this command
export PATH="/Users/YOUR SYSTEM USER NAME/Library/Android/sdk/platform-tools":$PATH
above command is for running android from MAC pc.
then last command is
4.adb reverse tcp:8081 tcp:8081
hit enter
or you can check reference that given in official site
Running On Device React Native
You must update Tools sdk revision 23.0.1 on Android Studio
I am building an app using react-native and i was using android default emulator without any problems. The only issue i am having is the emulator is really slow.
I wanted to try genymotion and installed it. How ever when i run react-native run-android it cannot find the Genymotion Emulator. Here is the Error i am seeing in the console.
BUILD SUCCESSFUL
Total time: 8.329 secs
This build could be faster, please consider using the Gradle Daemon: http://gradle.org/docs/2.4/userguide/gradle_daemon.html
ADB server didn't ACK
* failed to start daemon *
error:
Starting the app (/home/hduser/Android/Sdk//platform-tools/adb shell am start -n com.legacitinative/.MainActivity...
error: no devices/emulators found
I am not sure why it cannot find the emulator.
Appreciate any help.
Thanks
Sateesh
$ cd /home/hduser/Android/Sdk/platform-tools
$ ./adb reverse tcp:8081 tcp:8081
Try if adb can see your device with
$ ./adb devices