1. 環(huán)境搭建
主要準(zhǔn)備 ‘模擬器’ 設(shè)備
你需要準(zhǔn)備一臺(tái) Android 設(shè)備來(lái)運(yùn)行 React Native Android 應(yīng)用。這里所指的設(shè)備既可以是真機(jī),也可以是模擬器。Android 官方提供了名為 Android Virtual Device(簡(jiǎn)稱 AVD)的模擬器,如何安裝AVD。
2. 創(chuàng)建新項(xiàng)目
Install the CLI
$ npm i -g expo-cli
創(chuàng)建新項(xiàng)目
$ npx create-react-native-app
創(chuàng)建過(guò)程可選
Need to install the following packages:
create-react-native-app
Ok to proceed? (y) y
? What is your app named? … react-app
? How would you like to start ? Template from expo/examples
? Pick an example ? with-typescript
? Downloaded and extracted project files.
Using npm to install packages.
? Installed JavaScript dependencies.
? Your project is ready!
3. 項(xiàng)目運(yùn)行
$ npm start
npm start
> react-app@1.0.0 start
> expo start
Starting project at /homeyummyc/Documents/newVo/yummyc/yumy-github/react-app
Starting Metro Bundler
可以直接掃此處二維碼真機(jī)調(diào)試
? Metro waiting on exp://192.168.7.23:19000
? Scan the QR code above with Expo Go (Android) or the Camera app (iOS)
? Press a │ open Android
? Press w │ open web
? Press j │ open debugger
? Press r │ reload app
? Press m │ toggle menu
? Press ? │ show all commands
// 此處按a 打開AVD
Logs for your project will appear below. Press Ctrl+C to exit.
? Opening on Android...
搭建成功效果圖

效果圖
3. 項(xiàng)目打包
- expo平臺(tái)注冊(cè)一個(gè)賬號(hào)
- 開始打包
$ sudo npm install -g eas-cli
$ eas build -p android