React Native Expo构建的Bundle在Google Play Console中SDK版本识别异常
我是Google Play Console新手,上传React Native Expo构建的Bundle时遇到问题:控制台提示应用目标API等级为30,要求至少达到31,但我的构建实际使用的SDK版本为44。我尝试将SDK版本从44降至31,分别使用expo build:android和eas build --platform android命令构建,问题仍未解决。我还尝试配置了expo-build-properties插件依旧无效。
Google Play Console提示信息:
目前您的应用目标API等级为30,但必须至少为31,以确保应用使用最新API编译,获得最佳安全性和性能。请将应用目标API等级改为31或更高。
已配置的expo-build-properties代码:
"plugins": [ [ "expo-build-properties", { "android": { "minSdkVersion": 31, "compileSdkVersion": 31, "targetSdkVersion": 31, "buildToolsVersion": "31.0.0" }, "ios": { "deploymentTarget": "13.0" } } ] ]
1. 匹配expo-build-properties插件版本
确保expo-build-properties插件版本与当前Expo SDK版本兼容,Expo SDK 44对应的插件版本建议锁定在~0.2.1,执行安装命令:
npm install expo-build-properties@~0.2.1
2. 排查配置覆盖问题
检查app.json或app.config.js中是否存在其他配置节点(比如第三方插件)覆盖了targetSdkVersion,同时确保配置文件语法正确,没有导出错误。
3. 清除构建缓存
Expo的缓存可能保留旧配置,执行对应命令清除后重新构建:
- 针对
expo build:android:expo build:android --clear-cache - 针对EAS Build:
eas build --platform android --clear-cache
4. 检查EAS Build配置(若使用EAS)
如果用EAS Build,需确保eas.json的构建profile没有覆盖Android配置,可在对应profile中添加:
"android": { "buildType": "app-bundle", "gradleCommand": ":app:bundleRelease" }
同时确认构建环境使用的是与SDK 44匹配的镜像。
5. 验证构建包的实际API等级
用aapt工具检查构建后的AAB/APK的targetSdkVersion,确认配置是否生效:
aapt dump badging your-app-file.aab | grep targetSdkVersion
如果输出为31,可能是Google Play Console缓存问题,等待一段时间后重新上传;如果还是30,继续排查配置未生效的原因。
6. 裸工作流备选方案(谨慎操作)
若上述方法均无效,可考虑eject到裸工作流,直接修改android/app/build.gradle:
android { defaultConfig { minSdkVersion 31 targetSdkVersion 31 compileSdkVersion 31 } }
注意:eject后将无法继续使用Managed工作流特性。
内容的提问来源于stack exchange,提问作者Nicolás Esteban

