How to show metro bundler in new terminal when execute react-native run-android? - react-native

the command react-native run-android not opening metro bundler in new terminal on ubuntu. it only show starting js server and other react-native messages, and the app run normally.
when I tried it on windows or mac, metro bundler always opened in new terminal whenever I run react-native run-android and the port is available.
I am using ubuntu 16.04, react-native 0.57.8
what should I add to the command to make it behave like on windows or mac?
I am expecting it will run metro bundler in new terminal on ubuntu just like on windows or mac. thanks.

Related

React Native Android App run on emulator doesn't connect to metro bundler when installed using android-studio

My React-Native(0.68.1) project runs properly on my emulator when using npx react-native run-android command and everything works fine with the metro bundler instance created by this command.
Only when I run project from android studio (2021.3.1 Patch 1) , app is build successfully and installed on emulator, but cannot connect to metro bundler (which I separately run using npx react-native start command).
I wanted to try and update the debug server & port as mentioned in other similar questions , but I cannot access the debug app menu even after dismissing the error (menu doesn't show when ipress the shortcut)
Issue also occurs on build installed on emulator via npx react-native run-android when I close the app and metro bundler created by the command and start a separate metro bundler. In this case but I am able to enter settings menu and enter "debug server and port " to 10.0.2.2:8081 and app connects to metro.
I am using mac mini m1.
To fix this issue
first of all, start your emulator and run adb reverse tcp:8081 tcp:8081 this command on the terminal and then run npx react-native start and then run your project in the android studio and it will automatically link your app to that bundle

No apps connected. Sending "devMenu" to all React Native apps failed

This is a strange error when I ran React Native (0.63.2) app on Android 8.1 emulator with
npx react-native run-android
Here is the full warning message:
warn No apps connected. Sending "devMenu" to all React Native apps failed. Make sure your app is running in the simulator or on a phone connected via USB.
info Opening developer menu...
Tried adb reverse tcp:8081 tcp:8081 but didn't help. The emulator was working fine. What can go wrong here?
Note: Answer targets only those visitors, who are facing this issue after successfully running once on device
npx react-native run-android
//once its installed on device next time just do
npx react-native start
installs app at your device on first run. I was facing same issue only when I tried npx react-native run-android second time.
So I used npx react-native start then
I just opened my latest app installed by last run and its working and showing me the updates as well

React Native Android Studio Emulator launch issue

When I try to start my react-native init project with this command npx react-native start nothing happens in the emulator.
enter image description here
Command npx react-native start is for starting up the bundler (Metro)
to run it on an android emulator or device you need npx react-native run-android.
Before that please make sure you have either a real device connected or an emulator ready.
You can follow or check by using this guide for your Android environment setup.

Getting Building iOS bundle error when trying to build an android app - expo -react-native

I was able to build app using expo build:android previously. However, after upgrading to latest expo version I get following error:
connect ECONNREFUSED 127.0.0.1:19001
Set EXPO_DEBUG=true in your env to view the stack trace.
I also see the following lines in the log:
Publishing to channel 'default'...
Building iOS bundle
I don't added ios to my app.json, I only need to build an android apk. To do that I use expo build:android -t app-bundle
I also removed package-lock.json and node_modules and run npm install, but I get the same error.
I run expo start on another cmd and then run expo build:android -t app-bundle still get same error
Also when I clear expo cache, see the following log:
Restarting Metro Bundler...
Starting Metro Bundler on port 19001.
Couldn't adb reverse: adb.exe: error: Invalid source port: 'undefined'
I had faced same issue myself and found the solution. Expo is looking for localhost:19001 which is not running. Just follow following steps and it should work as expected:
Run expo start no terminal and once it opens up the
browser where you will find this line written Starting Metro
Bundler on port 19001.
Now open another terminal instance and run expo build:android.

react-native run-android not working on ubuntu 16.04

i have a problem with react native in ubuntu, i have installed,
java jdk 8 (both javac --version) as well as echo $JAVA_HOME gives the proper output.
I have also installed android studio and set the android environment variables as well as the tools and echo $ANDROID_HOME gives output of the sdk location.
I have also installed gradle version 4.4.
I am unable to start the android app using react-native run-android. can any one let me know if i have missed something during installation.
And react-native as well as android studio works fine as I am currently using react-native start to start the metro builder as well as the other react-native cli commands. also android studio and gradle is also able to generate debug as well as release apks with no problems.
The error i get,
Scanning folders for symlinks in /home/igate-naveed/Documents/ReactNative/mobile-app-android/node_modules (16ms)
Starting JS server...
Building and installing the app on the device (cd android && ./gradlew installDebug)...
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/getting-started.html
First of all you need to create a project like this:
react-native init myProjectName
Then, start an emulator from Android Studio... Afterwards:
npm install && npm start
in your project directory, and from another terminal, inside your project directory, run :
react-native run-android
Is this working?
Instead of using the npm install manager, I used yarn and it worked for me. In your project directory, just do:
(project-directory)$ yarn
Update the gradle version.
Create new project:
react-native init projectname
Uninstall the npm pack.
Reinstall the npm pack again.
npm start
react-native start
react-native run-android