使用expo-build-properties修改Target API Level无效,如何解决?
解决expo-build-properties配置targetSdkVersion不生效的问题
你的配置写法本身没问题,但可能是以下几个细节没处理到位导致不生效:
先确认expo-build-properties依赖已安装
光在plugins里加配置没用,必须先安装这个包:npx expo install expo-build-properties检查app.config.js的结构是否正确
确保配置是放在expo.plugins数组内,完整结构示例:export default { expo: { name: "你的应用名", slug: "你的应用slug", // 其他基础配置... plugins: [ [ "expo-build-properties", { android: { compileSdkVersion: 31, targetSdkVersion: 31, buildToolsVersion: "31.0.0", }, }, ], // 其他插件配置... ], }, };别把plugins数组放在expo对象外面,也不要嵌套错误。
检查eas.json是否覆盖了配置
如果你的eas.json里的build profile指定了targetSdkVersion,会优先覆盖app.config.js的设置。比如检查production配置:{ "build": { "production": { "android": { "buildType": "app-bundle", // 如果这里有targetSdkVersion: 30,改成31或者删掉 } } } }清理缓存后重新构建
旧的构建缓存可能导致配置不生效,先清理本地缓存:npx expo prebuild --clean然后在触发EAS Build时,勾选「Clean build cache」选项,确保用新配置构建。
验证构建产物的实际API等级
用aapt工具检查生成的AAB包,确认实际targetSdkVersion:aapt dump badging 你的应用包.aab | grep targetSdkVersion如果输出是targetSdkVersion:31,那可能是Google Play的缓存延迟,等一段时间再刷新页面;如果还是30,说明构建过程中配置没生效,回到前面的步骤排查。
确认Expo SDK版本兼容性
expo-build-properties修改targetSdkVersion的功能需要Expo SDK 44及以上版本支持,如果你用的是更旧的SDK,需要先升级SDK版本。
内容的提问来源于stack exchange,提问作者mycellius
相关产品推荐
相关产品推荐

