1, refer to the previous blog post "Mac react Native iOS Environment build", the previous steps are necessary, but the original client inconsistent
2. Installation of Android Studio
A: Installing the SDK for Java
Note: Android studio requires Java development Kit [JDK] 1.8 or later. You can enter on the command line javac -version to view the JDK version you are currently installing. If the version is not required, you can download it on the official website
B: Please do not change the options during installation unless otherwise noted. For example, Android Studio installed by default Android Support Repository , and this is react native must, otherwise in react-native run-android will be reported APPCOMPAT-V7 package can not find the error
C: There are some options that need to be changed during installation
Tick performance and Android Virtual Device
When the installation is complete, select it in the launch Welcome screen of Android StudioConfigure | SDK Manager
In the SDK Platforms window, select Show Package Details, then tick Google APIs, Android SDK Platform 23, Intel x86 Ato in Android 6.0 (Marshmallow) M system image, Intel x86 atom_64 system image, and Google APIs Intel x86 atom_64 System image
In the SDK Tools window, select Show Package Details , and then Android SDK Build Tools tick in Android SDK Build-Tools 23.0.1 (this version must be). And then check the bottom of theAndroid Support Repository
D:android_home Environment variables
Make sure that the ANDROID_HOME environment variables correctly point to the path of the Android SDK that you installed. This is done by adding the following command to the ~/.bash_profile file: ~ denotes the user directory, that is /Users/你的用户名/ , the file at the beginning of the decimal point is hidden in the Finder, and the file may not exist. Please vi ~/.bash_profile create or edit a command under terminal using commands
# If you don't have an SDK installed through Android Studio, the path may be different, so make sure you know for yourself.
Export ANDROID_HOME=~/LIBRARY/ANDROID/SDK
Then use the following command to make it effective immediately (or restart before it takes effect):source ~/.bash_profile
You can use to echo $ANDROID_HOME check if this variable is set correctly
E: Add the Tools directory of the Android SDK to the PATH variable
You can add the tools and Platform-tools directories of the Android SDK to PATH variables to run some Android tools in the terminal, for example, android avd or so on adb logcat . The specific practice is still ~/.bash_profile added in:
export PATH=$PATH:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools
3. Option to install
A:gradle Daemon: Turning on Gradle Daemon can greatly increase the speed of incremental compilation of Java code.
touch ~/.gradle/gradle.properties && echo "org.gradle.daemon=true" >> ~/.gradle/gradle.properties
B: Genymotion
4. Test Installation
react-native init AwesomeProject
cd AwesomeProject
react-native run-android
react-native run-android遇到的问题以及解决方案:
A:Gradle sync didn't respond to suspended animation
Solution: First You need FQ to use a proxy
First step: Find gradle-wrapper.properties This file in the project and see distributionurl=https\://services.gradle.org/distributions/ Gradle-2.14.1-all.zip, so you know the version number.
The second step: here to explain Gradle version needs to use 2.14.1, or change this version number to your existing Gradle version can also, so the following steps do not have to do, the direct Sync Gradle project is normal
Step three: Download your own Internet access to this package: Gradle-2.14.1-all.zip
Fourth Step: Enter the directory/USERS/XXXXXX/.GRADLE/WRAPPER/DISTS/GRADLE-2.14.1-ALL/8BNWG5HD3W55IOFP58KHBP6YV, (8bnwg5hd3w55iofp58khbp6yv this folder each machine is different), the contents of all the deleted
Fifth step: Put the downloaded gradle-2.14.1-all.zip here
Sixth step: Restart Android Studio,gradle will pass smoothly
B: Prompt No device
Android Stdio run up and select a device, or install a generymotion
Mac under react Native Android Environment setup