Setting up the Development Environment (Windows as an example)

Software must be installed

###### Chocolatey

Chocolatey(Chocolatey.org/) is a package manager for Windows, similar to yum and apt-get on Linux. You can check out the instructions on its official website. The general installation steps would be as follows:

@powershell -NoProfile -ExecutionPolicy Bypass -Command "iex ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1'))"&& SET PATH=%PATH%; %ALLUSERSPROFILE%\chocolatey\binCopy the code

In general, installing software with Chocolatey requires running a command prompt window as an administrator. Chocolatey’s website may be inaccessible in the country, preventing the above installation from being completed properly. Use a stable climbing tool. If you really can’t fit the tool, don’t worry. Python2 and NodeJS can be downloaded and installed separately from their respective official websites.

Python 2

Open a command prompt window and use Chocolatey to install Python 2. Note that Python 3 is not currently supported

choco install python2
Copy the code
Node

Open a command prompt window and install NodeJS using Chocolatey.

choco install nodejs.install
Copy the code

Note: Do not use CNPM! CNPM installed module path is strange, packager can not correctly identify!

npm config set registry [https://registry.npm.taobao.org](https://registry.npm.taobao.org/) --globalnpm config set disturl [https://npm.taobao.org/dist](https://npm.taobao.org/dist) --global

Copy the code
Yarn and React Native command line tools (react-native CLI)

Yarn(yarnpkg.com/zh-Hans/) is an alternative to NPM provided by Facebook to speed up the download of Node modules. React Native’s command-line tools perform tasks such as creating, initializing, updating projects, and running the Packager service.

 npm install -g yarn react-native-cli
Copy the code

After installing YARN, set the image source as follows:

yarn config set registry https://registry.npm.taobao.org --global
yarn config set disturl https://npm.taobao.org/dist --global
Copy the code

If you encounter an EACCES: permission denied error, run the following command (Linux only) : sudo NPM install -g yarn react-native-cli. After installing YARN, you can use yarn to replace NPM. For example, use yarn to replace NPM install. Use yarn to add the name of a third-party library instead of NPM install –save the name of a third-party library.

Android Studio configuration

*Android Studio requires Java Development Kit [JDK] 1.8 (later versions are not supported). You can view the JDK version you currently have installed by typing javac -version on the command line. If the version does not meet your requirements, you can download it from the official website. Choco install jdk8 or apt-get install default-jdk

Do not change the installation options unless otherwise specified. For example, Android Studio installs Android Support Repository by default, which is required by React Native. *

Of particular note are: Select Google APIs, Android SDK Platform 23, Intel x86 Atom 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 check Android SDK build-Tools 23.0.1 under Android SDK Build Tools (this version must be included). Of course, if other plug-ins require other versions, you can install multiple versions at the same time). Then check the Android Support Repository at the bottom.

Recommended Installation tools

Gradle Daemon (https://docs.gradle.org/2.9/userguide/gradle_daemon.html),if not exist "%USERPROFILE%/.gradle" mkdir "%USERPROFILE%/.gradle") && (echo org.gradle.daemon=true >> "%USERPROFILE%/.gradle/gradle.properties")
Copy the code

Test the installation

react-native init AwesomeProject
cd AwesomeProject
react-native run-android
Copy the code

The following interface is displayed after you enter the command line:

It indicates that the system is successfully started, and the construction of the development environment under Windows is completed.

Tip: You can use the –version parameter to create a project of the specified version. Example: React-native init MyApp –version 0.44.3. Note that the version number must be accurate to two decimal points.

Note to Windows users, do not init projects in the default System32 directory on the command line! There will be all kinds of permission restrictions can not run!

If the following problems occur

At the end of the article to send welfare!!

At the same time, after years of collection, I have also collected a complete set of learning materials and high-definition detailed Android architecture advanced learning maps and notes to share with you for free, hoping to be a friend of architects have certain reference and help. ** The following is part of the data screenshot, sincere full: especially suitable for Android programmers with development experience to learn.

Information for free access: now follow me and join the group chat group number: 1018342383 or click the link to join the group chat [Android development exchange] : jq.qq.com/?_wv=1027&k…