(I'm almost a newbie in React Native development) today I have started a new project in React Native 0.60 (react-native init MyApp).
After that I typed : react-native run-android to check if everything worked.
After the bundle process is finished
I can finally get my welcome screen in my connected devices
But, if I try to reload the app from my devices I get this error:
How could I address this error ?
EDIT: Thank you for your answers, anyway, I have tried all solutions you suggest but I still get the same problem. I also noticed that when i run react-native run-android Metro Bundler (open in a new cli window) seems to start but it suddenly disappear. I think the problem could be with the message 'Deprecated Gradle features were used in this build, making it incompatible with Gradle 6.0'
react-native run-android not working in new react-native version
0.60
now you can use
react-native start
OR
npm start
both command is work
Please use the following two commands and then can start the react native again.
- adb reverse tcp:8081 tcp:8081
- killall node
Then you can run the following the command.
react-native start
Now you can run your application again.
Have a good day.
You need to connect your phone to the server, follow the below steps:
[For detailed help follow this https://facebook.github.io/react-native/docs/running-on-device]
1. Open the developer menu on phone.
2. Open 'Debug server host & port for device'.
3. Type in your machine's IP address and the port of the local dev server (eg. 10.0.1.1:8081). If you have connected over wifi then this will be your computers ip address. (If you are running in your computer I think instead of ip address it would be 'localhost:8081')
4. Go back to the Dev menu and select reload.
Hope it would help.
You need to run adb reverse in the Android Studio terminal so your device can connect to the server. Open Android Studio and click on the terminal button at the bottom. In the terminal, and with your device connected to your computer, enter the command adb devices. This will list the name of the connected Android device. Copy that name. Then enter this command adb -s <device name> reverse tcp:8081 tcp:8081. When you run that command replace <device name> with the name of your device you copied from the other command.
Here is a link to an explanation in the React Native documentation
Related
adb devices detect my physical phone but react-native run-android command open my emulator..
and whenever i put this command npx react-native run-android --deviceId=97e2bc510706 it shows error no emulator or android device connected I WILL GET THIS ERROR
if you have android studio , open your project's android folder in android studio and run in your physical device and in vs code run command npx react-native start and if you are using mobile hotspot then open your app and shake your device or long press minimize button , go to setting and in port add your ip (for example : ,196.168.0.1:8081) after ip put your port number.
hope it will work ...!
Always remember sdk path not contain any space in my case my username of computer is shrivastava ji so there is space in my username so remove space in your username or file name or change the sdk path where path have no space
am new to React native Expo I need to add some new modules on my project. "expo": "33.0.0", "react": "16.8.3", whenever I try to run my project am getting Error am not able to run the project. I tried all way to run the project like set REACT_NATIVE_PACKAGER_HOSTNAME='192.168.0.102', firewall off, allowed inbound 19000 port etc. but am getting error.
when I enter expo start -c
Your project may not work correctly until you install the correct versions of the packages.
To install the correct versions of these packages, please run: expo install [package-name ...]
Starting Metro Bundler on port 19001.
Your JavaScript transform cache is empty, rebuilding (this may take a minute).
Your native app is running at exp9c305c55e38f4d0e856f59397620314e://192.168.0.101:19000
Logs for your project will appear below. Press Ctrl+C to exit.
then my laptop and mobile is connected with same network and same IP but am getting error and i don't know the port 19000 is different from my wifi
Uncaught Error:java.net.SocketTimeoutException:failed to connect to/192.168.1.20(port 19000)from/192.168.0.102(port 49615) after 10000ms
Please give some solution for it.
It's failing because port 19000 is not open in your firewall. If you use linux OS open this port by running:
sudo ufw allow 19000/tcp
enter image description hereFirst Check are you in tunnel connection?
If you are in tunnel connection then
First : ipconfig
then : set REACT_NATIVE_PACKAGER_HOSTNAME=192.168.1.103 (IPv4 Address)
then:npm start
It worked for me. Hopefully it will help.
I resolved this by changing the network profile on the connected wifi from private to public.
Expo Error Fix
I've weird problem with react native. My first app worked great on emulator and building was fine but now when I tried to run my second app on emulator i reciving an error:
Could not connect to development server and possible fixes under it.
Why is this happening? I did all the same like last time when all worked.
Emulator is visible for adb:
C:\Users\Computer>adb devices
List of devices attached
emulator-5554 device
react-native run-android:
BUILD SUCCESSFUL
Total time: 41.496 secs
Running ANDROID_HOME=C:\Users\Bartas\AppData\Local\Android\sdk/platform-
tools/adb -s emulator-5554 reverse tcp:8081 tcp:8081
Could not run adb reverse: spawnSync
ANDROID_HOME=C:\Users\Bartas\AppData\Local\
Android\sdk/platform-tools/adb ENOENT
Starting the app on emulator-5554
(ANDROID_HOME=C:\Users\Bartas\AppData\Local\An
droid\sdk/platform-tools/adb -s emulator-5554 shell am start -n
com.auth/com.auth.MainActivity)...
Okey, asked question too fast on stack.. Soory..
The problem was that my var had that value:
'ANDROID_HOME=C:\Users\Bartas\AppData\Local\Android\sdk/platform- tools/adb'
Just deleted 'ANDROID_HOME=' part and it works again.
I compiled react-native on Android v4.4.2 but the problems arised:
I tried to follow this solution, but I did not how to run on Command Prompt Windows 10:
$> cd myproject
$> react-native start > /dev/null 2>&1 &
$> curl "http://localhost:8081/index.android.bundle?platform=android" -o
> "android/app/src/main/assets/index.android.bundle
$> (cd android/ && ./gradlew assembleDebug)
I tried to compile the same way on Android V6.0. Then there was no problem at all.
How to make android V4.4.2 also can be use like Android v6.0 for my first react-native
project development?
That error means your React Native app can't fetch your JS files from your localhost. You'd usually just run react-native start to serve the JS files from your packager, but Android 4.4.x cannot connect to your localhost with the default adb reverse method.
The way I run on Android 4.4.x is to manually set the device to connect to my machine via Wi-Fi (Official guide here!).
Access the React Native dev menu by shaking your device or pressing the hardware menu button (can be done with Ctrl+M or Cmd+M in a simulator, IIRC)
Go to Dev Settings
Under the Debugging section, tap "Debug server host & port for device"
Enter your machine's IP address, as well as the port through which the React Native packager is serving, e.g. "10.0.0.25:8081" (make sure your device and your machine are on the same network!)
Reload through the dev menu again (or by pressing Ctrl+R or Cmd+R in a simulator, I think)
Try running this command
adb reverse tcp:8081 tcp:8081
As I was trying to install the app in my emulator through command prompt, it shows--
"error- more than one device and emulator."
I've 4 emulator but only 1 was online while I was installing the app.
I use this command (without quotes)
"adb install .apk"
Need help!!
close emulator, close adb. open and reconnect, you can use
adb devices
to see connected devices.