React Native run on multiple simultaneous Android emulators - javascript

I would like to test my app on at least 2 Android emulators simultaneously. I can start 2 emulators but can't seem to find how to react-native run-android my app on 2 emulators with ADB. If possible I would also like to be able to run a react-native log-android on each one while testing my app.
Is there a way to do so ?

You can only do it on different ports. Because one port, one listener :/
Solve:
react-native start --port 9988
./emulator -port 9988 -avd devicename1
react-native start --port 9999
./emulator -port 9999 -avd devicename2
Edit2:
Before running the emulator, You can write in the terminal and then run it:
function emulator { cd "$(dirname "$(which emulator)")" && ./emulator "$#"; }
First emulator is react .
emulator -port 9988 #react
react-native run-android ( automaticaly detect emulator )
Second emulator is r .
emulator -port 8081 #r
react-native run-android (automaticaly detect emulator )

In order to run your react application on multiple emulators, just start 2 emulators as usual and then use the command react-native run-android.
You can even specify any port number as react-native run-android --port 8084 if you want. Your app will start on both the emulators simultaneously. :)
Have a look here

The accepted answer by #Burhan Yılmaz did NOT work for me. This is probably due to new updates and development in the relevant software. The following steps demonstrate what worked for me.
Start the 1st emulator, e.g.
emulator -avd Nexus_S_API_28
Start the 2nd emulator, e.g.
emulator -avd Nexus_S_API_28_2
Start React-Native in the same way, which you would usually use (without specifying any ports.)
react-native run-android
This sends a copy of the code to both devices. However, each device runs its copy in isolation from the other device.
Environment Details:
MS Windows 10
Android SDK 29.0.2
React-Native: 0.61.2

Using Genymotion, you just have to start 2 instances and start them as if there was only one (react-native run-android to install the app and react-native start)

Related

how to run cloned/github remote react native app, err msg no android

NOTES: Im new in react native and i see there are so many approaches and with this error i thought the developer who built this app build it differently from what i learn so i don't understand why he didn't put the android folder
so i just joined a project and im going to run the apps in my pc by cloning it from github but when i try to npx react-native run-android it failed to run and the log is like this
error Android project not found. Are you sure this is a React Native project?
If your Android files are located in a non-standard location (e.g. not inside 'android' folder),
consider setting project.android.sourceDir option to point to a new location.
info Run CLI with --verbose flag for more details.
the folder structure is like this
The files show that the project is created with Expo. Specifically, you have a managed expo project.
npx react-native run-android would compile an android app from source, with Expo's managed workflow that's not needed. You will need the Expo Go App.
Expo also comes with its own commands to start the bundler. Instead of running npx react-native ... make use of the expo-cli running: npx expo start
However, in the package.json there is very likely a script called start. In that case, it's easier for you to run npm start.
After running this command the expo console opens. Here you can press a to open the app using expo go (or instructions on how to do so).
Alternatively, you can run npx expo run:android to start the expo go app on android yourself.
you are using an expo, there is a folder named .expo-shared, after
npm install
Try to run
npm start
or
expo start
or
npx expo start
something like this will appear:
https://imgur.com/U9I7Gf4
after that go to the terminal, open the emulator in you computer and click on the terminal and press 'a',

Stuck on info starting JS server

I have initiated successfully a new react-native project. Then, every time I try to run my newly built project using the command react-native run-android, it gets stucks on info Starting JS server....
Here is the output:
$ react-native run-android
info Running jetifier to migrate libraries to AndroidX".
You can disable it using "--no-jetifier" flag.
Jetifier found 855 file(s) to forward-jetify. Using 4 workers...
info Starting JS server..."
I tried restarting the laptop and switching emulators. I don't know what else to do anymore.
How do I solve the problem?
Kill the automatically popped up metro bundler command prompt
Kill the command terminal which is running react-native run-android
Now Run react-native start This will start your js server
In new command prompt window run react-native run-android
The app came up in 5 mins in an emulator.
Linux:
Go to the terminal and type:
react-native start
and then in OTHER terminal, inside your project folder:
yarn android
or
npm run android
Temporary fix:
REACT_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
font: https://github.com/facebook/react-native/issues/26097
I had the same problem. I started a project yesterday and it worked, started a new one today and it didn't work. The problem seems to be "#react-native-community/cli-platform-android". The version that showed up today is 2.8.2 as opposed to 2.7.0 for yesterday's project.
I used:
npm install #react-native-community/cli-platform-android#2.7.0
This is not a optimal solution, but it will get you going.
I had the exact same frustrating issue for a very different reason than mentioned in other answers.
As explained in this SO answer Android adb binds to port 5037 and I installed some program which took this port so adb was hanging silently (why adb! .. say something!)
Commands to test if this your issue cause:
test any adb command and see if it hangs, eg:
adb devices
If it does, then check who is using the port:
sudo lsof -i :5037
In my case(Manjaro OS)
First:
npm start
Then in a separate terminal:
npm run android
The best solution that I constantly find myself using, is going to the application manager on android, then clearing the data of the app. Running the app afterwards goes smoothly without lagging.
Reinstalling android studio with a new emulator or changing the app name in app.json , build.gradle and android manifest.xml solved the issue.

Error while starting react-native application

I am not able to run react-native on port 8088. Sometimes it runs and sometimes it doesn't. Last time I restarted the laptop so it ran and now again it isn't running. Is there any permanent solution?
The command should be:
react-native start --port 8088
You can use this command to check the options:
react-native start --help

React Native DeviceInfo native module is not installed correctly

I'm trying to run a React-Native application on my Android device which is a Huawei Honor 7, the device is connected to the pc through USB and I'm running it through command with: react-native run-android why am I getting this error?
Check this issue: https://github.com/rebeccahughes/react-native-device-info/issues/176
Looks like you just need to reinstall node_modules

Build app for ios (react-native)

I used command: 'react-native run-ios' and I have a message "Build Succeeded", but when I can find app to install on my iphone?
There are two different things here.
Running react-native run-ios will run your application on your simulator.
To run it in your device, you'll need to run the application from xCode. You can check RN's official docs on running on device here.

Categories

Resources