April 06, 2017
React Native is a framework built by Facebook to build native apps using React. React Native is built around the objective - learn once, write anywhere.
Though lot of plugins and modules are still in active development, it gained lot of popularity along with React. Facebook uses React Native in lot of their production apps. Lot of UI and utility libraries are already available for React Native.
In this we are going to setup an Android Development environment for React Native apps in Windows.
After you install Android Studio, open SDK Manager and make sure the following packages are installed as well.
Under Show Package Details tab, in Android 6.0 (Marshmallow) or Higher. The following should be enabled
You can either run your React Native app directly in you mobile phone by connecting it to the PC or use a virtual emulator aka AVD: Android Virtual Device.
Once you setup your AVD(emulator) you can launch it directly from terminal.
To list down all the emulators
> emulator -list-avds
To launch your emulator
> emulator -avd emulator-name
Now that we have installed all the prerequisites for our React Native app. Lets set up a sample project.
> react-native init SampleProject
React Native init is a bootstrap command to setup everything you needed for your app.
You have to run the server separately in a terminal and execute your app separately in a terminal. In the recent version, both terminals are launched by one command
> react-native start
If you don’t see the emulator and server starting separately. Open a new terminal and execute the command
> react-native run-android
You SampleProject should launch in the emulator now. To refresh the app
> Press F2 or Ctrl + M or Ctrl + R