Loading react native issue on emulator GenyMotion - android

I am using react native
react-native-cli: 2.0.1
react-native: 0.55.3
I was running via
react-native run-android
The screen is always loading the app (Debugger Mode)
NOTE: It was sudden issue, it was working fine till yesterday.
*PC is Restarted several time and also JS server using kill -9 PID

I've met this error before when I started to programming React Native on Ubuntu.
The reason why you got this error because your Genymotion didn't have same port with local machine.
So here is the solution:
Open the Developer Menu of mobile app on Genymotion
Choose the Debug Server port & port for device
Set the value localhost:8081
reload the app and enable the Debug. Now you can debug the app.
Cheer!

Maybe it is a problem with the app already installed in your phone.
Try running :
adb uninstall com.yourproject
This will install all of your project packages for all users on your emulator/phone

Temporary fix:
REACT_TERMINAL=<your terminal> react-native run-android
in my case with manjaro + xfce4:
REACT_TERMINAL=xfce4-terminal react-native run-android
or puts in your .bashrc:
export REACT_TERMINAL=xfce4-terminal

Related

React Native: Build APK that can connect to development server

I have an interesting scenario. It was an expo project that I converted to react-native. I don't have a react-native command (but can run npx react-native, but my understanding is to build the test APK I run yarn android which actually runs expo run:android.
However, my dev server is remote, so I'm looking to generate an APK and then use the developer menu to set the IP address of the dev server on the device, then connect to the react native server (i.e. not using Expo anymore)
How do I go about building this APK? When I use yarn android it says there are no devices connected and won't build.
Thanks!
npx react-native run-android builds an APK in ./android/app/build/outputs/apk but then fails. Just install this APK, then run it, shake the device to get the menu to pop up (or Cntrl-M for the menu on an emulator), settings, and dev server info is there (port 8081 default).

Could not connect to development server - react native error

I had a react native project that is working fine and I switched to another project which is also a react native project. When I came back to the development of the first project I ran the following commands. I use a physical device to debug.
cd ./projectfolder
react-native start --reset-cache
react-native run-android in another terminal
Now the following problems are there, I would like to know what are the causes.
react-native start starts the Metro Bundler but it does not show the
loading progress of the files after react-native run-android
finishes. (Does not serve files)
Still the application starts without any red screen. (How does this
happen if the Metro Bundler has no progress shown?)
Since the application starts I can shake the running device and try
to enable the hot loading but it gives a error on the red screen.
(Sorry for the bad quality, I got this from internet. The same message is there on my physical device.)
I have tried the following methods.
Clear the npm cache using npm cache clean --force.
Make sure that the laptop and the mobile are on the same wifi.
Add android:usesCleartextTraffic="true" to the manifest since there are Android 9 related changes as per most github answers.
Uninstall the application and trying to run again.
Restarting everything.
Ran the bundle command and try but it will not help start the debugger.
Can I have any help on this? Thanks in advance.

React Native opens to white screen in Android simulator

I created a new default project with React Native 0.60.4 and it opens ok in the iOS simulator, but when trying to open it on Android by selecting the project directory and then npm start, react-native run-android it opens to a white screen.
Then shortly after it returns an error message in the android emulator saying:
Unable to load script. Make sure you're either running a Metro server (run 'react-native start') or that your bundle is packaged correctly for release.
The Android simulator is working fine with Flutter so there should be no problem. I looked at other solutions for this issue and they say run react-native start first but I most certainly have done.
First run adb reverse tcp:8081 tcp:8081 on your terminal
You can find it in ~/Library/Android/sdk/platform_tools/
If that's not working please check your host ip and port on developer menu on android.
It can cause the issue on your side.

react-native run-android just rarely works

When I run react-native run-android I get the bellow Error:
BUILD FAILED
Total time: 19.668 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
But after running it for several times and having error, let say about five times, it works!
this process wastes so much of my time, so any suggestion is appreciated.
Install the app manually with adb in your emulator if not installed, then you could just use react-native start to start react native.
This problem occurred to me too.
If you don't have expo app installed on the emulator then download expo app and install it on your emulator, if you don't know how then see this post.
If you have it installed then clear the node cache as mentioned upwards and do npm start don't do npm start android, If don't work again then u reinstall all the packages but u must delete all the packages that are located on C:\Users\YOURUSERNAME\AppData\Roaming\npm and C:\Users\YOURUSERNAME\AppData\Roaming\npm-cache delete all those and then go here and create a new project from scratch, that worked for me.
And if you have expo software application on your computer don't use it ,it mess up your project with updates and so new problems come, just use the terminal.
Goodluck.
What helped me was to occasionally open and build the project using android studio. It will download all the gradle updates and android versions... most of the time I start the emulator from Android studio and the npm start to start the packager.

DeviceInfo native module is not installed correctly in react native

Hi I am trying to run my react-native android application on the device. It was working well, suddenly I am getting an error on running application.
DeviceInfo native module is not installed correctly
I have checked this DeviceInfo native module is not installed correctly but it did not work for me. I restarted my system to kill all process.
Can anyone help me how to solve this issue ?
D:\React Native\ReduxExample1>react-native -v
react-native-cli: 2.0.1
react-native: 0.44.0
D:\React Native\ReduxExample1>
I was running different application which is also built in react-native but did not run react-native server of that application. This was just my bad :)
I think this type of errors when you are not in the right packages. So as per my experience Make sure you have the right packager running in the terminal, sometimes you may have a packager associated with another react native project running, this happens because when you stop running a React Native project from Xcode or Android Studio, it doesn't stop the packager in the terminal, and when you start/open another React Native project in Xcode or Android Studio, it simply checks if a packager is running, doesn't check if it's associated with the current project. So make sure you stop all of the packager instances in the terminal and then open the React Native project again.

Categories

Resources