首页 > 解决方案 > 我无法在 Android 的 expo 环境中运行 React Native 应用程序

问题描述

我无法在 Android 的 expo 环境中运行 React Native 应用程序;在我的 Android 手机上运行 Expo 上的应用程序时会引发此错误:

Something went wrong.
32.0.0 is not a valid sdk version. Options are 35.0.0, 34.0.0, 33.0.0, UNVERSIONED.

相同的应用程序在我的 iOS 手机上的 Expo 环境中完美运行。

我从我的 MAC 启动“expo start”,并将两部手机连接到与我的 MACBOOK PRO 相同的 WIFI。

这是我的 app.json 文件:

{
  "expo": {
    "name": "travel-management-app",
    "slug": "travel-management-app",
    "description": "Travel management application",
    "privacy": "public",
    "sdkVersion": "32.0.0",
    "platforms": [
      "ios",
      "android"
    ],
    "version": "1.0.0",
    "orientation": "portrait",
    "primaryColor": "#cccccc",
    "icon": "./assets/icons/bg_screen5_square.png",
    "splash": {
      "image": "./assets/icons/bg_screen5.png"
    },
    "updates": {
      "fallbackToCacheTimeout": 0
    },
    "assetBundlePatterns": [
      "**/*"
    ],
    "ios": {
      "supportsTablet": true
    }
  }
}

这是我的 package.json 文件:

{
  "name": "travel-management-app",
  "version": "1.0.0",
  "description": "Travel management Application",
  "author": "Luchian Chivoiu",
  "private": true,
  "homepage": "https://www.sienna.ro",
  "main": "src/index.native.js",
  "dependencies": {
    "@babel/polyfill": "^7.2.5",
    "@expo/vector-icons": "^9.0.0",
    "expo": "^32.0.0",
    "expo-linear-gradient": "^3.0.0",
    "gh-pages": "^2.0.1",
    "lodash": "^4.17.4",
    "material-ui": "^0.20.2",
    "prop-types": "^15.7.2",
    "react": "16.5.0",
    "react-art": "^16.8.3",
    "react-autowhatever": "^10.2.0",
    "react-dom": "^16.8.3",
    "react-native": "https://github.com/expo/react-native/archive/sdk-32.0.0.tar.gz",
    "react-native-autocomplete-input": "^4.1.0",
    "react-native-elements": "^1.0.0-beta8",
    "react-native-gesture-handler": "1.0.17",
    "react-native-gesture-handler-web": "npm:react-native-gesture-handler@1.1.0",
    "react-native-keyboard-aware-scroll-view": "^0.9.1",
    "react-native-picker-select": "^6.3.3",
    "react-native-ratings": "^6.3.0",
    "react-native-touchable-scale": "2.0.0",
    "react-native-vector-icons": "^6.3.0",
    "react-native-web": "^0.10.0",
    "react-navigation": "^3.5.1",
    "react-navigation-animated-switch": "^0.2.1",
    "react-redux": "6.0.1",
    "react-scripts": "^2.1.5",
    "react-select": "^3.0.4",
    "redux": "^4.0.4",
    "redux-thunk": "^2.3.0"
  },
  "scripts": {
    "web": "react-app-rewired start",
    "native": "expo start",
    "build:web": "react-app-rewired build",
    "deploy": "gh-pages -d build",
    "build:android": "expo ba",
    "build:ios": "expo bi",
    "eject:web": "react-scripts eject",
    "eject:native": "expo eject",
    "prettify": "prettier --write 'src/**/*.js'",
    "clean-install": "rm -rf node_modules && npm cache clean --force && watchman watch-del-all && yarn"
  },
  "devDependencies": {
    "@babel/plugin-proposal-class-properties": "^7.3.4",
    "babel-preset-expo": "^5.0.0",
    "customize-cra": "^0.2.12",
    "prettier": "^1.15.3",
    "react-app-rewired": "^2.1.0"
  },
  "browserslist": [
    ">0.2%",
    "not dead",
    "not ie <= 11",
    "not op_mini all"
  ]
}

package-lock.json 包含以下内容:

"react-native": {
      "version": "https://github.com/expo/react-native/archive/sdk-32.0.0.tar.gz",
      "integrity": "sha512-+taJh7bN2owmwaZpJUrNpHdmPAL6ZynNCZj15uLQgjaPFq0ZBIG2ZWuSJ48eGoUjAb3lrWxkmLlHb2eJFXc7sQ==",

我怎样才能在Android上也能做到这一点?这个应用程序几天前在我的 Android 手机上运行,​​直到我做了一些包更新。

我更新了一些东西,一些包,一个包,也许这使得这个 Android expo 应用程序无法运行。

标签: reactjsreact-nativereact-native-androidexpo

解决方案


您使用的是过时的 Expo SDK 和应用程序,SDK 32 及以下版本不再维护。

按照此链接上的说明进行操作,您应该一切顺利

希望这可以帮助!


推荐阅读