不兼容的SDK版本或无SDK版本Expo Go。

8

摘要

错误信息:"运行请求的应用程序时出现问题"。 "不兼容的SDK版本或未指定SDK版本。此版本的Expo Go仅支持以下SDKS:44.0.0、45.0.0、46.0.0。"

在任何设备(Android或iOS)和任何模拟器(Android或iOS)上使用npx expo start运行应用程序。

尝试expo upgrade,结果表明我不需要升级。 尝试删除node_modules并重新运行yarn。 尝试删除模拟器上的expo go客户端并重新安装它。

问题链接 expo issues

有解决方案吗?

出现问题的平台:

iOS

SDK版本

46

环境

  expo-env-info 1.0.5 environment info:
    System:
      OS: macOS 12.6
      Shell: 5.8.1 - /bin/zsh
    Binaries:
      Node: 16.14.2 - /usr/local/bin/node
      Yarn: 1.22.19 - /usr/local/bin/yarn
      npm: 8.5.0 - /usr/local/bin/npm
    Managers:
      CocoaPods: 1.11.3 - /usr/local/bin/pod
    SDKs:
      iOS SDK:
        Platforms: DriverKit 21.4, iOS 16.0, macOS 12.3, tvOS 16.0, watchOS 9.0
    IDEs:
      Android Studio: 2021.3 AI-213.7172.25.2113.9014738
      Xcode: 14.0.1/14A400 - /usr/bin/xcodebuild
    npmPackages:
      @expo/metro-config: ^0.4.0 => 0.4.0 
      expo: 46.0.0 => 46.0.0 
      react: 18.0.0 => 18.0.0 
      react-dom: 18.0.0 => 18.0.0 
      react-native: 0.69.5 => 0.69.5 
      react-native-web: ~0.18.7 => 0.18.9 
    npmGlobalPackages:
      eas-cli: 2.3.0
      expo-cli: 6.0.6
    Expo Workflow: bare

最小可复现示例

package.json文件

{
  "scripts": {
    "start": "expo start --dev-client",
    "android": "expo run:android",
    "ios": "expo run:ios",
    "web": "expo start --web",
    "eject": "expo eject",
    "test": "jest --watchAll",
    "debug": "open 'rndebugger://set-debugger-loc?host=localhost&port=19000'"
  },
  "jest": {
    "preset": "jest-expo"
  },
  "dependencies": {
    "@expo-google-fonts/raleway": "^0.2.2",
    "@expo/config-plugins": "^5.0.0",
    "@expo/metro-config": "^0.4.0",
    "@expo/vector-icons": "^13.0.0",
    "@react-native-async-storage/async-storage": "~1.17.3",
    "@react-native-community/datetimepicker": "6.2.0",
    "@react-native-masked-view/masked-view": "0.2.7",
    "@react-navigation/bottom-tabs": "^6.4.0",
    "@react-navigation/native": "^6.0.13",
    "@react-navigation/native-stack": "^6.9.0",
    "@react-navigation/stack": "^6.3.1",
    "@reduxjs/toolkit": "^1.8.5",
    "@rneui/base": "^4.0.0-rc.6",
    "@rneui/themed": "^4.0.0-rc.6",
    "@sentry/react-native": "4.2.2",
    "@stripe/stripe-react-native": "^0.19.0",
    "dotenv": "^16.0.2",
    "expo": "46.0.0",
    "expo-app-loading": "~2.1.0",
    "expo-apple-authentication": "~4.3.0",
    "expo-application": "~4.2.2",
    "expo-background-fetch": "~10.3.0",
    "expo-build-properties": "~0.3.0",
    "expo-camera": "~12.3.0",
    "expo-constants": "~13.2.4",
    "expo-dev-client": "1.3.1",
    "expo-device": "~4.3.0",
    "expo-image-loader": "~3.2.0",
    "expo-image-manipulator": "~10.4.0",
    "expo-image-picker": "~13.3.1",
    "expo-keep-awake": "~10.2.0",
    "expo-linear-gradient": "~11.4.0",
    "expo-local-authentication": "~12.3.0",
    "expo-media-library": "~14.2.0",
    "expo-modules-autolinking": "~0.10.1",
    "expo-modules-core": "0.11.7",
    "expo-notifications": "~0.16.1",
    "expo-screen-capture": "~4.3.0",
    "expo-splash-screen": "~0.16.2",
    "expo-status-bar": "~1.4.0",
    "expo-system-ui": "~1.3.0",
    "expo-task-manager": "~10.3.0",
    "expo-updates": "~0.14.6",
    "expo-web-browser": "~11.0.0",
    "firebase": "^9.10.0",
    "react": "18.0.0",
    "react-dom": "18.0.0",
    "react-native": "0.69.5",
    "react-native-agora": "^3.7.1",
    "react-native-bouncy-checkbox": "^3.0.4",
    "react-native-calendars": "^1.1289.0",
    "react-native-date-picker": "^4.2.5",
    "react-native-dotenv": "^3.3.1",
    "react-native-element-dropdown": "^2.3.0",
    "react-native-gesture-handler": "~2.5.0",
    "react-native-gifted-chat": "^1.0.4",
    "react-native-paper": "^4.12.5",
    "react-native-progress": "^5.0.0",
    "react-native-reanimated": "~2.9.1",
    "react-native-safe-area-context": "4.3.1",
    "react-native-screens": "~3.15.0",
    "react-native-svg": "12.3.0",
    "react-native-toast-message": "^2.1.5",
    "react-native-uuid": "^2.0.1",
    "react-native-vector-icons": "^9.2.0",
    "react-native-web": "~0.18.7",
    "react-native-webview": "11.23.0",
    "react-redux": "^8.0.4",
    "redux": "^4.2.0",
    "redux-saga": "^1.2.1",
    "redux-thunk": "^2.4.1",
    "sentry-expo": "~5.0.0"
  },
  "devDependencies": {
    "@babel/core": "^7.18.6",
    "@types/react": "~18.0.0",
    "@types/react-dom": "~18.0.0",
    "@types/react-native": "~0.69.1",
    "@types/react-redux": "^7.1.24",
    "expo-module-scripts": "^2.1.1",
    "jest": "^26.6.3",
    "jest-expo": "^46.0.0",
    "react-test-renderer": "^18.2.0",
    "remote-redux-devtools": "^0.5.16",
    "typescript": "^4.6.3"
  },
  "resolutions": {
    "standard-version-expo/**/@expo/config-plugins": "4.1.0",
    "@types/react": "~18.0.0",
    "@types/react-dom": "~18.0.0",
    "@types/react-native": "~0.69.1"
  },
  "private": true,
  "name": "hammashelppi-app",
  "version": "2.0.0"
}

app.json

{
  "expo": {
    "name": "Hammashelppi",
    "slug": "hammashelppi",
    "version": "2.0.0",
    "orientation": "portrait",
    "icon": "./images/HH_Logo.png",
    "splash": {
      "image": "./images/HH_splash_image.png",
      "resizeMode": "contain",
      "backgroundColor": "#107CA2"
    },
    "userInterfaceStyle": "light",
    "developmentClient": {
      "silentLaunch": true
    },
    "packagerOpts": {
      "config": "metro.config.js",
      "sourceExts": [
        "expo.ts",
        "expo.tsx",
        "expo.js",
        "expo.jsx",
        "ts",
        "tsx",
        "js",
        "jsx",
        "json",
        "wasm",
        "svg"
      ]
    },
    "updates": {
      "fallbackToCacheTimeout": 300000,
      "enabled": true,
      "url": "https://u.expo.dev/****"
    },
    "assetBundlePatterns": ["**/*"],
    "web": {
      "favicon": "./images/favicon.png"
    },
    "hooks": {
      "postPublish": [
        {
          "file": "sentry-expo/upload-sourcemaps",
          "config": {
            "organization": "hammashelppi",
            "project": "hammashelppi",
            "authToken": "*****"
          }
        }
      ]
    },
    "plugins": [
      [
        "@stripe/stripe-react-native",
        {
          "merchantIdentifier": "****",
          "enableGooglePay": true
        }
      ],
      [
        "expo-image-picker",
        {
          "photosPermission": "Allow Hammashelppi to access your gallery.",
          "cameraPermission": "Allow Hammashelppi to access your camera."
        }
      ],
      ["expo-camera"],
      [
        "expo-notifications",
        {
          "icon": "./images/HH_android_notifications_white.png",
          "color": "#107CA2",
          "mode": "production"
        }
      ],
      "sentry-expo",
      [
        "expo-build-properties",
        {
          "android": {
            "compileSdkVersion": 31,
            "targetSdkVersion": 31,
            "buildToolsVersion": "30.0.2",
            "kotlinVersion": "1.7.10"
          }
        }
      ]
    ],
    "android": {
      "icon": "./images/HH_android_logo_old.png",
      "googleServicesFile": "./google-services.json",
      "adaptiveIcon": {
        "foregroundImage": "./images/HH_android_logo.png",
        "backgroundColor": "#107CA2"
      },
      "package": "fi.suujahammas.hammashelppi",
      "versionCode": 14,
      "permissions": [
        "NOTIFICATIONS",
        "CAMERA",
        "READ_EXTERNAL_STORAGE",
        "RECORD_AUDIO",
        "android.permission.RECORD_AUDIO",
        "android.permission.CAMERA"
      ],
      "useNextNotificationsApi": true
    },
    "ios": {
      "supportsTablet": true,
      "bundleIdentifier": "fi.suujahammas.hammashelppi",
      "infoPlist": {
        "NSFaceIDUsageDescription": "Face ID is used for authentication",
        "UIBackgroundModes": ["fetch", "remote-notification"]
      },
      "buildNumber": "14",
      "googleServicesFile": "./GoogleService-Info.plist"
    },
    "runtimeVersion": "2.0.0",
    "extra": {
      "eas": {
        "projectId": "***"
      }
    }
  }
}

eas.json

{
  "cli": {
    "version": ">= 0.52.0"
  },
  "build": {
    "development": {
      "developmentClient": true,
      "distribution": "internal",
      "env": {}
    },
    "development-android": {
      "extends": "development",
      "android": {
        "buildType": "apk",
        "gradleCommand": ":app:assembleRelease"
      }
    },
    "development-ios": {
      "extends": "development",
      "ios": {
        "enterpriseProvisioning": "universal"
      },
      "cache": {
        "key": "18999"
      }
    },

    "preview-android": {
      "extends": "development",
      "channel": "preview-android",
      "developmentClient": false,
      "android": {
        "buildType": "app-bundle",
        "gradleCommand": ":app:bundleRelease"
      }
    },
    "preview-ios": {
      "extends": "development",
      "channel": "preview-ios",
      "developmentClient": false,
      "ios": {
        "enterpriseProvisioning": "universal"
      },
      "cache": {
        "key": "18999"
      }
    },

    "production-android": {
      "extends": "development",
      "distribution": "store",
      "channel": "production-android",
      "developmentClient": false
    },
    "production-ios": {
      "extends": "development",
      "distribution": "store",
      "channel": "production-ios",
      "developmentClient": false
    }
  },
  "submit": {}
}

有什么解决办法吗? - Kasra
4个回答

11

当我将expo版本升级到47时,也遇到了同样的问题。我通过以下步骤解决了这个问题:

  1. 删除node_modulepackage-lock.json文件
  2. 在app.json文件中将policy更改为sdkVersion,如下所示: enter image description here
  3. 运行npm install

它对我起作用了!否则,您需要安装开发构建并运行“expo start --dev-client”,这很麻烦。 - Costas_

1
I struggled a lot with this error but managed to fix it, really satyender gives the correct answer but not quite try to change it in my app.json by changing Version to: 

"runtimeVersion": {
  "policy": "sdkVersion"
}
1. - I did the following in the android part of your app.json: you need to delete 
"runtimeVersion": "2.0.0"or "1.0.0" the same with the ios part and right there in that part add: 

"runtimeVersion": {
  "policy": "sdkVersion"
}

it looks as: "android": {
  "adaptiveIcon": {
    "foregroundImage": "./assets/adaptive-icon.png",
    "backgroundColor": "#FFFFFF"
  },
  "package": "com.danyrivas13.AppDeliveryReactNative",
  "runtimeVersion": {
    "policy": "sdkVersion"
  }
},
first to android and then to ios,
both with: "runtimeVersion": {
  "policy": "sdkVersion"
}
it looks as: "ios": {
  "supportsTablet": true,
  "runtimeVersion": {
    "policy": "sdkVersion"
  }
},
2. - Then you have to delete your node_modules and your package-lock.json
3. - Then Npm Install 
4. - Your project should already compile in my case npx expo start and that worked for me.
    }
    
    it looks as: "android": {
      "adaptiveIcon": {
        "foregroundImage": "./assets/adaptive-icon.png",
        "backgroundColor": "#FFFFFF"
      },
      "package": "com.danyrivas13.AppDeliveryReactNative",
      "runtimeVersion": {
        "policy": "sdkVersion"
      }
    },
    first to android and then to ios,
    both with: "runtimeVersion": {
      "policy": "sdkVersion"
    }
    it looks as: "ios": {
      "supportsTablet": true,
      "runtimeVersion": {
        "policy": "sdkVersion"
      }
    },
    2. - Then you have to delete your node_modules and your package-lock.json
    
    3. - Then Npm Install 
    4. - Your project should already compile in my case npx expo start and that worked for me.

目前你的回答不够清晰,请编辑并添加更多细节,以帮助其他人理解它如何回答问题。你可以在帮助中心找到有关如何撰写好答案的更多信息。 - Community

0
如果您使用expo-cli doctor --fix-dependencies,它将更改所有依赖包以匹配expo所需的版本!

0

按照以下5个综合但简单的步骤:

1- 在 app.config.js 或 .ts 文件中,您必须添加

runtimeVersion: {
      policy: 'sdkVersion',
    }

2- 删除 node_module 和 package-lock.json 文件
3- 运行 npm i 或 yarn
4- 无论在哪个设备上运行,都必须有一个构建(例如,如果您第一次运行 yarn start,则步骤1不足):
yarn expo run:android (or ios instead of android or npm instead of yarn)

5- 随时都可以放心地运行yarn start或npm start!附注:如果在扫描QR码时遇到问题,请手动输入在Expo Go中显示的URL,这对我起作用了(例如:exp://192.168.0.137:8081)。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接