I'm working on Windows 7. first connection is working, but reload doesn't work and it says no device attached and check by "adb devices", turned to offline. Windows 10 works and no error.
In your package.json under scripts you can add something like this :
"android-dev": "adb reverse tcp:8081 tcp:8081 && react-native run-android"
Then you can simply run npm run android-dev and you're all set.
Related
I am working on a simple react project on Windows 10 Pro. On trying to run the project with wsl with zsh (npm start) everything works, I get warnings and compilation is done without any errors. The issue I am facing is automatic launch of browser from wsl is not happening.
If I manually open localhost:3000 on my chrome after this command everything works but I would like the wsl terminal to launch my browser on npm start automatically just like it does in most of my other terminals and powershell on windows.
What I have tried:
added a export browser property to my .zshrc with path to chrome from here
Added a bsconfig file to root with following code to set open = true as per from here
I have added the ports from 3000-3999 to my firewall so that wsl can access my host (localhost ip). this fixed previous issue where localhost:3000 would show connection refused error.
I would be happy to provide any more details.
I am very new to wsl and zsh and I would really appreciate any help. Thanks
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
Build is successfully getting run but the development server is closing, as of that my React-native app is not able to run on emulator
You can check the error on the emulator, kindly do tell me the reason.
You could try adb reverse tcp:8081 tcp:8081 in cmd and it could help you.
(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
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.