-
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
-
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
Run
react-native init myProject
create React-Native ProjectRun
cd myProject
switch to the project root directory, runadb devices
to ensure that the device is connected to the computerRun
react-native run-android
packed Android project compiled and deployed to the emulator or development machineBefore running a command, to ensure that the device is connected to a computer, you can run
adb devices
to 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;Note: The first package when the network will download
gradle
a file related to the need to wait for a long time, you can directly fromhttp://www.androiddevtools.cn/
manually download the corresponding version of thegradle
file, unzip and manually copy toC:\Users\自己的用户名\.gradle\wrapper\dists
the directory;-
Note: Next, if it is the first time packaged, from
https://jcenter.bintray.com
downloading a lot of dependencies, this time need to be patient, if the middle there has been a long time Caton, we need toCtrl+C
stop the package, and re-runreact-native run-android
Note: If the License for package Android SDK Build-Tools 28.0.3 not accepted, then the error,
Reproduced in: https: //www.jianshu.com/p/ab8bf4128b0e