There's a question from 2015 for the then current Android Studio how to change the default Emulator. Much seems to have changed since then as the accepted answer is no longer relevant (see below). So I'm asking a similar question anew, for the current tooling:
How can I set the default Android Emulator to use for a React Native project? Currently it always defaults to (a) the currently running emulator, or if there is none to (b) the first emulator I'd ever created on my machine.
If relevant, my context:
java version 11.0.18adb version 34.0.1emulator version 32.1.12.0react-native project version 0.72.3 (React Native CLI getting started, with default setupIf I run yarn android it'll pick the running or otherwise it will start the emulator I created first, a Pixel 6.
How can I change the default emulator picked for (especially) react native applications I'll create on my machine?
Failed workaround
Although I'd prefer to change the default emulator on my PC for all projects (I tend to create new RN apps often), I guess a mediocre workaround would be to be able to specify the device when running. I tried to get that workaround up but also failed at that. I tried the answers to this other question and ran:
emulator -list-avds
Which gives me:
Nexus_5_API_33 Pixel_4a_API_33_2 Pixel_6_API_33
and then:
yarn android --deviceId=--deviceId=Pixel_4a_API_33_2
But that fails after this output:
yarn run v1.22.19 $ react-native run-android --deviceId=--deviceId=Pixel_4a_API_33_2 info JS server already running. error No Android device or emulator connected. Done in 1.10s.
Other things I've tried
emulator -help (didn't see anything)C:\Users\[username]\.android\avd to see if there was some kind of "is default" option somewhere, couldn't find anythingSomehow React Native decides which emulator to use by default, but I can't find out how this works. Is there any reasonable way to change this?
Somehow React Native decides which emulator to use by default, but I can't find out how this works. Is there any reasonable way to change this?
When there is no device running (virtual or physical) React Native will pick the first device from Android Studio's Device Manager.
I was having the same problem as you with React Native. The most obvious solution is to run the emulator you want before running your react app but i didn't like this solution.
So the quick and dirty "fix" i did was to rename the emulator i would like to be default with a number as a prefix.
For example:
"Pixel 6a API 33"
rename to
"1.Pixel 6a API 33"
This way the emulator moved up to the top of the list and now launch as default.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With