Unable to connect development server. Ensure that the packager server is running - android

I am a starter of React-native tho I am having trouble with debugging. Program is successfully installing apk to emulator but can not render the component. Whenever I double press 'R' (I am on windows) it throws following error

Try:
cd YourProject
react-native run-android
react-native start

Related

React Native works with a real device but not with an android emulator

OS: Linux Ubuntu
CLI or Expo: CLI
RN Version: 0.70.6
I start my React Native project with the following commands:
yarn start
yarn react-native run-android
It works when a real device connected to my PC and the project starts on my device. But it does not work with an Android Emulator.
When I try with an emulator:
yarn start command shows usual outputs. No error, nothing. Seems to work correctly
yarn react-native run-android also same. Build successful. No error or warning.
adb devices command shows my emulator correctly.
But emulator does not start my project. I can see my project icon on the emulator. When I double click to my project, I just see a blank screen for one second or less and it closed again.
When i try to reload metro using r command on terminal it says no apps connected.
I think the emulator builds the app but not connect to metro properly. I don't know why. I cannot see any error or warning messages.
I tried ./gradlew clean and delete node_modules and install but it didn't work.
I also tried yarn start --port 8081 but it also didn't work.
EDIT: For testing purpose, I created a new project with `npx react-native init AwesomeProject' and it works on the emulator. So I think the problem is only about the other project.
SOLUTION:
In my case it was because of Flipper version. When I changed it from 0.125 to 0.144 my project started on an android emulator properly.
Here is the link where i found the solution:
react-native-issue-in-github

How to fix "Error spawn Unknown system error -8" in react native

I have that weird error when running "npx react-native run-android" that is only occuring in a specific react native project only on my Macbook with android simulator. Other RN apps are running fine on my mac with android.
On a windows pc this specific RN app is also working fine.
Error: spawn Unknown system error -8
at ChildProcess.spawn (node:internal/child_process:413:11)
at Object.spawn (node:child_process:743:9)
at module.exports (/Users/hannes/Projects/test2/mapp/native-frame/node_modules/#react-native-community/cli-platform-android/node_modules/execa/index.js:205:26)
I tried the following things:
deleting package-lock.json
rm -r node_modules + gradlew clean (in android folder)
creating a new virtual device in android studio with API level according to build.gradle
upgrading node to 18.8.0
upgrading npm to 8.18.0
npm cache clean –force
Somebody any ideas?
After using "run-ios" in the meantime I had to face the problem again and found a solution.
npx react-native run-android
this line is using the port 8081 and my macbook did sometimes use this port for another service
lsof -i tcp:8081
this command showed the process that was running
COMMAND PID FD DEVICE SIZE/OFF NODE NAME
node 44492 24u 0t0 TCP *:sunproxyadmin (LISTEN)
I terminated this process but still got the error message.
So I called the gradle command for building and installing the app myself.
cd android && ./gradlew app:installDebug -PreactNativeDevServerPort=8081
This worked, the app got build and installed on my android device but I got multiple error messages in the android studio run console starting with:
Could not find generated setter for class
this error was also addressed on GitHub and Stackoverflow
So building and installing the app in production mode solved the problem for me.
./gradlew app:installRelease

React native - Unable to load script in android emulator

I ejected an expo project and tried running npm start and npx react-native run-android. The bundler runs and shows this
To reload the app press "r"
To open developer menu press "d"
The app is installed in the emulator, but shows the following error.
unable to load script. make sure you're either running a metro
server (run 'react-native start') or that your bundle
'index.android.bundle' is packaged correctly for release.
The emulator is able to reach the host machine IP address in the browser.
I tried the following solutions.
Run npm start or react-native start in the root directory of your project before react-native run-android
android:usesCleartextTraffic="true"
Changing port
Nothing helped me. What could be the issue?

React-native app is crashing without error in android studio

I am getting these errors ;
java.lang.RuntimeException: Unable to load script. Make sure you're either running a Metro server (run 'react-native start') or that your bundle 'index.android.bundle' is packaged correctly for release.
Open up a new tab in the terminal and in your project folder type react-native-start and then go back to the other tab and run your project by typing react-native run-android
By using react-native start you will see the metro bundler starting up and running. If you want to clear the metro cache then type the below in your project directory
react-native start --reset-cache

React Native response error 500

enter image description here]1
I am doing following step to start react application
react-native init reactTutorialApp
react-native run-android
by followed these steps and it is installing on Device successfully. but i am getting a following error.
The development server return response error code:500
PFA
I think you forgot to run one command, the one to start the development server.
Try:
react-native init reactTutorialApp
run the following command in the project root folder, but in another tab (this process need to be running when you're developing:
react-native start
And now you can run: react-native run-android
Tell me if it solve your problem.

Categories

Resources