android - React Expo 更改目标 Android API
问题描述
最近我们使用 react expo 构建 Android 应用程序并使用以下命令expo build:android -t apk
或 Android App Bundle构建签名 APKexpo build:android -t app-bundle
在我们构建签名 APK 后,我们尝试上传到 Playstore,但出现了一些错误,要求我们将目标 API 从 26 升级到 28。在 SO 上探索和阅读了几个 QA,其中许多是针对 React Native 的。我们如何将我们的 APK 发布到 Play 商店?
这里是app.json
{
"expo": {
"name": "***",
"slug": "***",
"privacy": "public",
"sdkVersion": "32.0.0",
"platforms": [
"ios",
"android"
],
"version": "1.2.3",
"orientation": "portrait",
"icon": "./assets/logo.png",
"splash": {
"image": "./assets/splash.png",
"resizeMode": "contain",
"backgroundColor": "#ffffff"
},
"updates": {
"enabled": true,
"checkAutomatically": "ON_LOAD",
"fallbackToCacheTimeout": 0
},
"assetBundlePatterns": [
"**/*"
],
"ios": {
"supportsTablet": true
},
"android": {
"package": "com.qreatiq.foodmart",
"permissions": [
"CAMERA"
],
"googleServicesFile": "./google-services.json",
},
}
}
我们已尝试检查文档here
,并且有 compileSDKVersion 或相关的属性,如本机应用程序。
在本机应用程序中,我们可以轻松配置如下
compileSdkVersion 27
buildToolsVersion "27.0.3"
minSdkVersion 16
targetSdkVersion 27
如何在 React Expo 上做到这一点?
当您上传 APK 时,它需要满足 Google Play 的目标 API 级别要求。从 2019 年 8 月 1 日开始,Google Play 要求新应用至少面向 Android 9.0(API 级别 28),并且应用更新从 2019 年 11 月 1 日起面向 Android 9.0。在这些日期之前,新应用和应用更新必须至少面向 Android 8.0(API 级别 26)。
对那些事情还是没有任何想法。
解决方案
按着这些次序:
- 关闭您的 Expo CLI 服务器
中
app.json
,更改sdkVersion
为"34.0.0"
在
package.json
中,更改这些依赖项:react-native
至"https://github.com/expo/react-native/archive/sdk-34.0.0.tar.gz"
expo
至"^34.0.3"
react
到"16.8.3"
——(这个确切的版本)react-navigation
至"^3.11.1"
jest-expo
到"^34.0.0"
(如果你使用它)sentry-expo
到"~1.13.0"
(如果你使用它)
如果你使用
react-navigation
你也应该运行expo install react-native-gesture-handler react-native-reanimated
删除项目
node_modules
目录并npm install
再次运行或使用yarn
跑
expo start -c
在这些步骤之后,它应该可以工作。
来源:https ://blog.expo.io/expo-sdk-34-is-now-available-4f7825239319
推荐阅读
- python - 将 Ym-dTH:M:Sz 转换为日期时间进行比较
- java - 如何在 Jolt Transformation 中循环时展平一组对象?
- javascript - 无法设置未定义的属性“”
- azure-devops - 如何使用 azure CLI 添加团队管理员?
- swiftui - 如何在 SwiftUI 中修复“线程 1:EXC_BAD_ACCESS(代码=2,地址=0x7ffee86aafd8)”
- javascript - noUiSlider(使用步骤 API)+ wNumb - wNumb 格式不适用于第一个工具提示
- typescript - 在运行时使用派生类扩展基实例
- glsl - 在 Three.js 中指定 WebGL2 上下文后,无法遍历 sampler2D 数组
- javascript - 如何使用javascript扩展切换?
- python - 为具有定义数量的参数的类使用多个构造函数