1. Mac IOS
1. Install Xcode
React Native currently requires Xcode 9.4 or higher. You can download it from the App Store or from the Apple Developer website. This step installs the Xcode IDE, Xcode’s command-line tools, and the iOS emulator at the same time.
2. Mac Android
If you’ve never worked on an Android development environment before, be prepared for the tedious process. Read the following instructions carefully and perform configuration operations according to the documents. If you are a domestic user, make sure you can surf the Internet scientifically. If you can’t use the Internet scientifically, you probably won’t be able to build your environment successfully. Please make sure that your wall climbing tool is stable enough. If the url appears in the error, it is 99.99% because you cannot climb the wall.
1. Install Android Studio
Download and install Android Studio first, domestic users may not be able to open the official link, please use the search engine to search available download links. On the installation screen, select the “Custom” option and make sure the following items are selected
- Android SDK
- Android SDK Platform
- Android SDK Platform (AMD Processor)
- Android Virtual Device
If the checkbox is gray, you can skip it and install the components laterCopy the code
2. Install the Android SDK
Android Studio installs the latest version of the Android SDK by default. Currently, building React Native apps requires an Android 9 (Pie) SDK (note that the SDK version is not the same as the terminal system version, RN currently supports Android 4.1 and above). You can choose to install each version of the SDK in Android Studio’s SDK Manager.
SDK Manager is available in Android Studio"Preferences"Found in the menu. The specific path is Appearance & Behavior → System Settings → Android SDK.Copy the code
Select and install the following
- Android SDK Platform 28
- Intel x86 Atom_64 System Image (official emulator Image file, use unofficial emulators do not need to install this component)
Then click on the “SDK Tools” TAB, again in the lower right corner of the check box “Show Package Details”. Expand the “Android SDK build-tools “option and make sure you have the 28.0.3 version required for React Native selected. You can install multiple other versions at the same time.
3. Configure the environment variable ANDROID_HOME
React Native requires environment variables to know what path your Android SDK is installed on so it can compile properly.
You need to add the following command to the ~/.bash_profile file.
If you don’t have a.bash_profile file in your ~/ directory, you can create it and edit it
vi ~/.bash_profile
Copy the code
# If you are not installing the SDK through Android Studio, the path may be different, please check for yourself.
export ANDROID_HOME=$HOME/Library/Android/sdk
export PATH=$PATH:$ANDROID_HOME/tools
export PATH=$PATH:$ANDROID_HOME/tools/bin
export PATH=$PATH:$ANDROID_HOME/platform-tools
export PATH=$PATH:$ANDROID_HOME/emulator
Copy the code
Use the source $HOME/.bash_profile command to make the environment variable Settings take effect immediately (otherwise, they won’t take effect until restart). You can check that this variable is set correctly using echo $ANDROID_HOME.
Make sure you specify the Android SDK path properly. You can do it in Android Studio"Preferences"Check the real path of SDK in the menu, specifically Appearance & Behavior → System Settings → Android SDK.Copy the code
4. Create virtual devices
Open Android Studio and create the virtual appliance in the upper right corner of the IDE. This step is slow, so you need to be patient.