Create Android emulator for React Native


React Native support for iOS simulator is seamless, just run
react-native run-ios and the iOS simulator will starts up, and runs automatically. However, to get react-native run-android working for an Android emulator, you'll need few extra steps.

Starts by checking if there's any recognized devices on your machine

$ adb devices


If you don't have any devices, you can start by creating an Android Virtual Device image.

$ android create avd -n -t --abi default/x86_64


--abi define the CPU architecture you want for the emulator. Use x86_64 so that the emulator would runs faster on an x86 machine. Here's a list of other ABI options.
 can be anything, such as "SamsungAvd" (or something that's easy to type).
 should be one of the options produced by the command below...


$ android list targets


If that listing is empty, use the android command's GUI to install a target platform and such.

When you have the platform, and the device, you can then boot the device with emulator:


$ emulator -avd


Once the emulator booted (it takes a while for first boot), run

react-native run-android


the React Native app will automatically install and run in the emulator.




Comments