首页 > 解决方案 > 如何在 Android 上使用应用程序运行 react-native(使用 CRNA)

问题描述

我有一个使用 CRNA 创建的简单应用程序,它在 iOS 上运行良好,但在 Android 上失败。

在此处输入图像描述

这似乎与 Android OS 上缺少的 JSC 有关。我在项目中添加了“android-jsc”(https://github.com/facebook/android-jsc)dep,但没有任何改变。我错过了什么?

这是我的package.json

{
  "name": "app",
  "version": "0.1.0",
  "private": true,
  "devDependencies": {
    "babel-plugin-module-resolver": "^2.7.1",
    "eslint": "^4.10.0",
    "eslint-plugin-react": "^7.4.0",
    "jest-expo": "^28.0.0",
    "jest-immutable-matchers": "^2.0.1",
    "react-native-scripts": "1.14.0",
    "react-test-renderer": "16.4.0"
  },
  "main": "./node_modules/react-native-scripts/build/bin/crna-entry.js",
  "scripts": {
    "start": "REACT_NATIVE_ENV=development react-native-scripts start",
    "eject": "react-native-scripts eject",
    "android": "react-native-scripts android",
    "ios": "react-native-scripts ios",
    "test": "REACT_NATIVE_ENV=test node node_modules/jest/bin/jest.js --watch",
    "test_ci": "REACT_NATIVE_ENV=test node node_modules/jest/bin/jest.js"
  },
  "jest": {
    "preset": "jest-expo"
  },
  "dependencies": {
    "jsc-android": "224109.x.x",
    "expo": "^29.0.0",
    "immutable": "^3.8.2",
    "momentjs": "^2.0.0",
    "prop-types": "^15.6.1",
    "react": "16.3.1",
    "react-native": "https://github.com/expo/react-native/archive/sdk-29.0.0.tar.gz",
    "react-native-elements": "1.0.0-beta5",
    "react-native-keyboard-aware-scroll-view": "^0.4.1",
    "react-native-modal-datetime-picker": "^6.0.0",
    "react-native-side-menu": "^1.1.3",
    "react-native-vector-icons": "^4.6.0",
    "react-navigation": "2.0.4",
    "react-redux": "^5.0.7",
    "redux": "^4.0.0",
    "redux-immutablejs": "^0.0.8",
    "redux-logger": "^3.0.6",
    "redux-thunk": "^2.2.0",
    "sentry-expo": "^1.9.0",
    "validate": "^4.4.1"
  }
}

标签: androidreact-nativejavascriptcorecreate-react-native-app

解决方案


jsc-android需要手动链接,与 Expo 不兼容。查看您的所有依赖项是否与 Expo 兼容。如果没有,您要么必须分离到 ExpoKit,要么寻找兼容的替代品。

编辑:经检查,您正在直接安装 react-native-vector-icons。它需要手动链接,但包含在 Expo 中。在这里查看说明。


推荐阅读