React Native building development environment official document: reactnative. Cn/docs / 0.51 / g…

After the environment is set up, run the following command according to the official document:

React-native init AwesomeProject // Create an AwesomeProject

CD AwesomeProject // Go to the AwesomeProject directory

React-native run-android // Install the app on android devices

Cannot find entry file index.android.js in any of the roots

Solutions:

1. In the project directory Android ->app-> SRC ->main, create the folder Assets

2. Run the following command in the project root directory:

 react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res/ 

In assets after the index will create two files. The android. The bundle, but android. Bundle. Meta

React-native run-Android could not connect to development server. Try the follwing to fix the issue:*

Solutions:

1. Shake the device to pop up the developer menu. Select Dev Setting and enter the computer’s Intranet IP address and service port number, for example, 192.168.1.3:8081

2. Run the project using YARN Start

3. Open the developer menu on the device and click Reload to change app.js and load the changed content on the device.

Make sure your device is connected successfully. You can enter ADB Devices to view:

$ adb devices 
List of devices attached 
emulator-5554 offline # Google Emulator 14ed2FCC Device # Real device
Copy the code