Quickly create ReactNative project

  1. After installing node recommend setting npm mirror to accelerate the process behind (or scientific use Internet tools). Note: Do not use cnpm! cnpm installed modules rather strange path, packager does not recognize normal! (Rn command-line tool does not recommend using npm and cnpm)

    npm config set registry https://registry.npm.taobao.org --global

    npm config set disturl https://npm.taobao.org/dist --global

  2. Yarn and React Native command-line tool (react-native-cli) (rn command-line tool recommended Yarn)

    • Yarn is an alternative npm tools provided by Facebook, you can speed up the download node module.

    • React Native command-line tool used to create, initialize, update project, run the Package Service (packager) and other tasks.

    npm install -g react-native-cli

    • Similarly also provided after the installation of the mirror source yarn:

    yarn config set registry https://registry.npm.taobao.org --global

    yarn config set disturl https://npm.taobao.org/dist --global

  3. Run react-native init myProjectcreate React-Native Project

  4. Run cd myProjectswitch to the project root directory, run adb devicesto ensure that the device is connected to the computer

  5. Run react-native run-androidpacked Android project compiled and deployed to the emulator or development machine

  6. Before running a command, to ensure that the device is connected to a computer, you can run adb devicesto view a list of devices currently accessed; if not checked device list, make sure the phone is turned on 开发者模式, while the driver to install the phone on your computer;

  7. Note: The first package when the network will download gradlea file related to the need to wait for a long time, you can directly from http://www.androiddevtools.cn/manually download the corresponding version of the gradlefile, unzip and manually copy to C:\Users\自己的用户名\.gradle\wrapper\diststhe directory;

  8. Note: Next, if it is the first time packaged, from https://jcenter.bintray.comdownloading a lot of dependencies, this time need to be patient, if the middle there has been a long time Caton, we need to Ctrl+Cstop the package, and re-runreact-native run-android

    13537242-e463ad9d534d865a.png
    After the project is created, balloon NOTE .png

Note: If the License for package Android SDK Build-Tools 28.0.3 not accepted, then the error,

13537242-f70ccffaf22111e9.png
.Png error problem
13537242-b190274da7cd9a5f.png
Error to solve the problem 2.png

Reproduced in: https: //www.jianshu.com/p/ab8bf4128b0e

Guess you like

Origin blog.csdn.net/weixin_34273046/article/details/91202368