How to run react-native expo app on multiple emulators? - android

Does anyone know how to run an expo react-native app on multiple android emulators at once?
I have tried to run the app after running the emulators but it would run only on one emulator.
When I tried 'shift+a' it shows a list of emulators but when I choose the desired emulator it doesn't work.
This is the error 'Couldn't start a project on Android: The emulator (Nexus_S_API_30) quit before it finished opening. You can try starting the emulator manually from the terminal with: emulator #Nexus_S_API_30'
This says the emulator exited even though it is already running.

Install app in all emulator
Open all emulator
Run project from different port
For example
Run 'npx react-native start' for first emulator
Run 'npx react-native start --port 9988' from another terminal for second emulator etc
Open app from emulators
Open developer menu by pressing ctrl + m
Change bundle location to '10.0.2.2:PortNumber' eg : '10.0.2.2:9988'

Related

react-native run-android not detecting emulator or device

When I run react-native run-android to run my React Native app I get this error and then the build fails:
'C:\Users\Alex\AppData\Local\Android\Sdk/platform-tools/adb' is not recognized as an internal or external command,
operable program or batch file.
error Failed to launch emulator. Reason: Emulator exited before boot..
warn Please launch an emulator manually or connect a device. Otherwise app may fail to launch.
I get this error whether I run the command with my phone connect by USB or if I run it with the emulator open from Android Studio. However, when I run adb devices both the emulator and my device show up.
I am pretty sure it is not a problem with the React Native code because I have tried running multiple different apps and get the same error.
Does anyone know what could be the problem and why the device and emulator aren't detected?
The problem was that my computer's antivirus had deleted adb.exe so once I reinstalled the platform tools folder containing adb.exe, react-native run-android worked as normal and my connected device was detected.

Command 'react-native log-android' stuck at 'Starting Logkitty'

I'm trying to run a React Native project and after trying to start it, it produces an error which I'm trying to debug, but while trying to debug that error the command gets stuck.
I've tried using 'react-native log-android' but for some reason it gets stuck at 'Starting logkitty'
I had the same issue and the following solution worked for me.
First make sure you have an adb device connected to your system by running the command adb devices from you terminal and check if any devices get listed under the line: List of devices attached.
Now after running the command react-native log-android, 'Reload' code on your device and the logkitty should start logging fine.
The terminal may keep showing "info Starting logkitty" after npx react-native log-android command.
The log data may appear if present, after navigating through the screens of the project in an android device or emulator which is running the project after npx react-native run-android command.

Expo run on android emulator using windows 10

Can I run android emulator without an android phone? I have installed android studio and I've already installed android virtual device. However, when I try to run it, it gives an error like this :
Couldn't start project on Android: Error running adb: No Android
device found. Please connect a device and follow the instructions here
to enable USB debugging:
https://developer.android.com/studio/run/device.html#developer-device-options.
If you are using Genymotion go to Settings -> ADB, select "Use custom
Android SDK tools", and point it at your Android SDK directory.
I just want to see the emulator in my pc without usb. I have an iPhone but it just shows up in my phone not in my pc using expo scan barcode. I don't want to do that because in my opinion it's not comfortable for debugging etc. I am using windows in my pc so I can't use iOS for emulator.
how to run expo android emulator on windows?
Yes you can:-(With zero android studio config)
Install expo-cli globally.
Install android Studio.
Create a project by running expo-cli init
No need of any configuration on android Studio.
Open existing Project from android studio
then Open the created expo Project it will be available as an android project with a
android logo on it
then open the AVD Manager
Download and install whichever device you want but see to that its above android N
and do it for x86
after Installing the desired emulator
run the emulator before running the project
then run expo start to start the Project
Go to the metro builder and say run android
if it doesn't run on the first go or if you get error close the project
from emulator from recents and do a run on android again from metro
builder don't close project just the running project from recent on emulator
then it should work
Maybe too late, but I found out that is simplier that what you think.
Install your Android SDK (studio)
Create new emulator: Go to Tools > AVD Manager > Create new virtual device
(I chosen Nexus, Android 7)
When you get new emulator installed try to find out list of it ( command: emulator -list-avds )
!! If you do not have emulator in the path follow this commands in PowerShell:
PATH = %PATH%;C:\Users\[YOURUSERPCNAME]\AppData\Local\Android\Sdk\platform-tools
PATH= %PATH%;C:\Users\[YOURUSERPCNAME]\AppData\Local\Android\Sdk\emulator
PATH= %PATH%;C:\Users\[YOURUSERPCNAME]\AppData\Local\Android\Sdk\tools\bin
Run your emulator: emulator -avd [NAMEOFYOUREMULATOR] from the command emulator -list-avds
When emulator runing go to your Expo root folder (wher package.json is) and run npm start
Click on run in Run on Android device/emulator
Enjoy coding
Edit for Linux users
my linux usecase is as follow:
Install Android studio and open it
Install any emulator using AVD manager and try it's working
Close studio and go to your android folder ~/Android/Sdk/(two options 'emulator/' or 'tools/'), basically you need to find emulator
list item ./emulator -list-avds
choose your emulator and run it ./emulator -avd <any emulator>
if emulator not work use sudo
if you do not get any options in Sdk folder but you installed emualtor than you did it propably as a superuser - then the easiest is to completely remove all android studio and install it again
Delete the directory C:\Users\Rizwan.expo\android-apk-cache and opening the project on android again
It will run
There is another way to solve this problem. Follow the steps below in the same order:
run expo start to start the Project
Wait for the metro builder to be displayed in the browser.
On the terminal, wait for all options to be displayed, like so: To run the app with live reloading, choose one of:
Now load a device from Android Virtual Device in Android Studio (which already has the folder containing expo project open). On the terminal, press the key a.
Then the app should now open on the device being emulated.

How to set the default Android Emulator

I am building an app with NativeScript, where I run:
$ tns run android --emulator
to build the app and launch it in an emulator. When I do this, the default android emulator boots on my machine, which is unusably slow...
In all the demos, they are using the Genymotion Emulator. I have installed this, but the NativeScript command still launches the default emulator. How do I get this to launch on the genymotion emulator?
NB: I am using Windows 10
Update:
Even if I run the command with the Genymotion emulator running (and nothing else), I get the following log output and a new terminal window is opened running android-sdk/tools/emulator-arm.exe
BUILD SUCCESSFUL
Total time: 11.959 secs
Project successfully built.
Using C:\Users\George\Source\Repos\NativeScript-App\Bluetooth\platforms\android\build\outputs\apk\bluetoothdemo-debug.apk
Starting Android emulator with image Xamarin_Android_API_23
That looks as though it is referencing the emulator I had been using when I was developing with Xamarin. Any ideas where I can change that, or why that is being called?
start Genymotion, then start one of the devices that you have setup in Genymotion
then check that the device is seen:
$ tns device
then run nativescript like so
$tns run android --geny 192.111.222.33:555
(or whatever is the name that you get from the tns device command)
To my experience --emulator always tries to start the stock emulators. Try to start genymotion and then just tns run android (w/o the --emulator option).
I think it does that when there is no emulator running.
Try starting Genymotion first, launch the image you want, then run the "tns run adroid" command.
I had a similar issue.
To use GenyMotion by default, first delete all the Android emulators using
android avd
I then followed the solution on this thread:
React-Native, Android, Genymotion: ADB server didn't ACK
Edit the settings in GenyMotion to use the android SDK you downloaded. (path for Windows is Users/YOUR-SYSTEM/AppData/Local/Android/android-sdk)
You still have to run the device on GenyMotion before running the emulator
tns run android

Ionic don't run android into Genymotion

I have get everything setup by following on this tutorial (http://learn.ionicframework.com/videos/windows-android/). The problem is now, when I run ionic run android, the adb doesn't get the apk install into the virtual device run by Genymotion.
However, if I manually navigate to platforms\android\build\outputs\apk\ folder and run adb install android-debug.apk, then run ionic run android again, it will install into the virtual device. Everytime after I did the changes, I need to run adb install, then it will work.
How can I overcome it? Thanks.

Categories

Resources