31.0.0 不是有效的 SDK 版本。选项是 26.0.0 未版本化

Posted

技术标签:

【中文标题】31.0.0 不是有效的 SDK 版本。选项是 26.0.0 未版本化【英文标题】:31.0.0 is not a valid SDK Version. Option are 26.0.0 Unversioned 【发布时间】:2019-04-29 18:32:41 【问题描述】:

将 expo 版本更新到 31.0.0 后,我无法再运行我的应用程序。由于 ios 版本 12 支持,我需要此升级。你尝试构建 android 应用程序后它不再工作。

我的 package.json 如下所示:


  "name": "myapp",
  "version": "0.1.0",
  "private": true,
  "devDependencies": 
    "react-native-scripts": "1.13.1",
    "jest-expo": "^31.0.0",
    "react-test-renderer": "16.3.0-alpha.1"
  ,
  "main": "./node_modules/react-native-scripts/build/bin/crna-entry.js",
  "scripts": 
    "start": "react-native-scripts start",
    "eject": "react-native-scripts eject",
    "android": "react-native-scripts android",
    "ios": "react-native-scripts ios",
    "test": "jest"
  ,
  "jest": 
    "preset": "jest-expo"
  ,
  "dependencies": 
    "axios": "^0.18.0",
    "expo": "^31.0.4",
    "react": "16.5.0",
    "react-native": "https://github.com/expo/react-native/archive/sdk-31.0.1.tar.gz",
    "react-native-image-slider": "^2.0.3",
    "react-native-onesignal": "^3.1.4",
    "react-native-progress": "^3.4.0",
    "react-native-render-html": "^3.9.3",
    "react-navigation": "^1.5.11"
  

app.json 看起来像:


  "expo": 
    "sdkVersion": "31.0.0",
    "name": "myapp",
    "slug": "myapp",
    "version": "0.1.1",
    "isDetached": true,
    "detach": 
      "scheme": "expe6b74e69f7904f4b8961fc359e0dc1ce",
      "androidExpoViewUrl": "https://s3.amazonaws.com/exp-exponent-view-code/android-v2.4.0-sdk26.0.0-e63d9209-070c-4118-b06b-c60e82da0b66.tar.gz"
    ,
    "android": 
      "package": "com.myapp"
    
  

Android build.gradle 应用如下所示:

android 
  compileSdkVersion 27
  buildToolsVersion '26.0.1'

  defaultConfig 
    applicationId 'com.ferrometal12'
    targetSdkVersion 27
    versionCode 1
    versionName '0.1.1'
    ndk 
      abiFilters 'armeabi-v7a', 'x86'
    
    multiDexEnabled true
    testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    // Deprecated. Used by net.openid:appauth
    manifestPlaceholders = [
      'appAuthRedirectScheme': 'host.exp.exponent'
    ]
  

知道为什么这不再适用于 Android 了吗?

注意:在我有 expo 26.0.0 之前,我也有 targetSdkVersion 到 26,在更新 expo 之后我也更新了 targetSdkVersion 到 27

更新:这个错误发生在模拟器上,我还没有在真实设备上尝试过,但我感觉在真实设备上也会出现同样的情况。

【问题讨论】:

我也有同样的问题。你找到解决方法了吗? 我看到你在package.json和app.json中有不同的sdk版本 我还没有找到任何解决方案,你呢? @Mizlul 刚刚添加了一个答案。 @Mizlul 我只是更新了 app.json 的 sdk :) 现在它可以工作了 【参考方案1】:

您必须在您的 Android 设备上卸载并安装 Expo。

【讨论】:

我的安卓设备上根本没有安装 expo! 修复了这个问题。 @Mizlul 当我们选择“在 Android 设备/模拟器上运行”时,expo 首先在模拟器上安装“Expo”应用程序,然后执行该应用程序。它在 Expo-CLI 和 Expo App 更新时发生。您只需从 Emulator 中卸载 Expo App 并运行项目(npm start),它将在您的 Emulator 上安装 Expo App 的更新版本。安卓手机也是一样,需要在手机上更新Expo App【参考方案2】:

从 android 的 play-store 更新了移动博览会应用程序。它对我有用。

【讨论】:

【参考方案3】:

见upgrade walk-trough ...


    "react-native": "https://github.com/expo/react-native/archive/sdk-31.0.0.tar.gz",
    "expo": "^31.0.0",
    "react": "16.5.0"

您更改的那个sdkVersion,很可能是Android SDK版本,应该是:

"sdkVersion": "26.0.0"

当前最大值为28.0.0,但当它要求26.0.0时,可能应该使用它。

【讨论】:

我会试试这个配置 我的 javascrip 版本与本机反应不匹配 如果您使用 expokit,请确保您的 package.json 中也包含最新版本的 expokit。【参考方案4】:

早安,

这是有效的

    如果您使用的是 android studio

在虚拟 android 设备中卸载 expo。 如果您不确定如何 要卸载,您可以在 Android Virtual 中删除虚拟设备 设备管理器,让所有的东西都被刷新。 重新安装虚拟设备

    如果您使用的是真正的安卓设备

找到expo并卸载它。

【讨论】:

@AndriyFM 我很高兴它有帮助【参考方案5】:

我的应用程序已分离/弹出,我正在使用 ExpoKit。以下配置对我有用:

package.json

"expo": "^31.0.6",
"expokit": "31.0.2",
"react": "16.5.0",
"react-native": "https://github.com/expo/react-native/archive/sdk-31.0.1.tar.gz",

app.json

"sdkVersion": "31.0.0"

看到upgrade walk-through

【讨论】:

【参考方案6】:

我今天遇到了这个问题; Playstore 更新此应用后,我的 Expo Android 应用出现此错误。

我通过安装旧版 Expo APP (您可以在 apkpure.com 上找到旧版 Playstore 应用)并下载支持 SDK 31.0.0 的 Expo Android App 2.12 版解决了这个问题

【讨论】:

【参考方案7】:

此步骤适用于已退出的展会项目:

如果您已经运行expo update 35.0.0 或其他版本,但它没有解决错误,并且您已经退出了您的 expo 项目...

检查您的app.json 中是否有正确的分离属性。请注意 URL 上 iosExpoViewURLandroidExpoViewURL 密钥的 sdk 编号。

"detach": 
  "iosExpoViewUrl": "https://s3.amazonaws.com/exp-exponent-view-code/ios-v2.13.0-sdk35.0.0-a30ebc9b-3db4-42f4-b677-e468076baf18.tar.gz",
  "androidExpoViewUrl": "https://s3.amazonaws.com/exp-exponent-view-code/android-v2.13.0-sdk35.0.0-b816b7af-88da-4ca9-87a5-7438f0c21b6e.tar.gz"

【讨论】:

【参考方案8】:

我遇到了同样的问题。通过清除 Android 设备上 Expo 应用程序的数据和缓存解决了该问题。现在可以正常使用了。

【讨论】:

【参考方案9】:

要解决这个问题,只需迁移到最新版本的 node 和 expo cli。在您的手机上卸载 expo 并从应用商店进行全新安装。你应该很高兴。

【讨论】:

以上是关于31.0.0 不是有效的 SDK 版本。选项是 26.0.0 未版本化的主要内容,如果未能解决你的问题,请参考以下文章

Installed Build Tools revision 31.0.0 is corrupted. Remove and install again using the SDK Manager解决

Installed Build Tools revision 31.0.0 is corrupted. Remove and install again using the SDK Manager解决

Installed Build Tools revision 31.0.0 is corrupted. Remove and install again using the SDK Manager解决

Installed Build Tools revision 31.0.0 is corrupted. Remove and install again using the SDK Manager解决

Installed Build Tools revision 31.0.0 is corrupted. Remove and install again using the SDK Manager.(

6.0.1 的基础 SDK 在 Xcode 中不是一个选项吗?