Troubleshooting setting up a React Native Android dev environment

React Native is awesome, but the docs leave something to be desired, particularly for Android (the RN team is working on it!). I recently wanted to get started on building an Android version of the completed iOS app I previously shipped using React Native, but it turned out to be an overly painful process. The docs assume knowledge of Android development, which I do not have, so here are the steps I used to get up and running on my Mac.

Open Android Studio from Applications, step through the setup wizard to download all the packages it needs (about 250MB)

To run the emulator, you need to create a Virtual Device
– Use AVD Manager to create a virtual device (https://developer.android.com/studio/run/managing-avds.html). I chose to use a Nexus 5X emulator for no other reason as it was the default selected one.
– Run that device by clicking on the green Play button

In your terminal, change directory to the root of your React Native app, and runreact-native run-android

If at this point your React Native app shows up in your emulator, congrats, you’re now a React Native Android developer!

It turns out I had generated my project on an earlier version of React Native, as I was working on the iOS version first, and the Android code it generated was no longer compatible with React Native v0.32. To fix this:

Create a temporary folder

mkdir ~/tempFolder

cd ~/tempFolder

Now create a new React Native application with the exact same name as your application in that folder. This is important as the React Native tools embed that in a number of files that they generate.

react-native init MyAppName

Rename the folder in your original app “/android/app” to something else, e.g. “/android/app_old_and_busted”

Copy the folder ~/tempFolder/MyAppName/android/app to the “android” folder in your app.

run the command “react-native run-android” from the root of your app again.