expo/React Native 使用第三方包react-native-webrtc EAS构建

471 阅读1分钟

比如我们要使用 react-native-video,和react-native-webrtc 这个包,但是expo 直接使用会报错。

📢📢📢注意终端需要配置一下代理vpn(我用的clashX 不然eas build 一直上传失败)

export https_proxy=http://127.0.0.1:7890 http_proxy=http://127.0.0.1:7890 all_proxy=socks5://127.0.0.1:7890

从头开始

  1. npx create-expo-app webRtc-Video-demo
    
  2. package.json

    "react-native-video": "6.0.0-alpha.4",
    "react-native-webrtc": "111.0.3",
    "@config-plugins/react-native-webrtc": "7.0.0",
    
  3. app.json

    "plugins": [
          "@config-plugins/react-native-webrtc"
     ],
    
  4. 实际上react-native-video 可以用expo-av 替代,播放流视频靠webrtcView

  5. yarn
    
  6. 转换成 云/本地 开发版 创建开发版本 - Expo Documentation --- Create a development build - Expo Documentation

    npm install -g eas-cli
    npx expo install expo-dev-client
    eas login
    eas build (直接运行下面是不是也行。。。)
    eas build --profile development --platform android (我只能搞了Android ios 要apple付费账号,这个需要等一下时间,它会生成一个包含原生库的expo go的apk,相当于官方那个expo go应用的定制版吧。)
    
  7. 顺利的话应该就好了,yarn start 启动项目,扫描二维码后用安装的apk启动就好了。