You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用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

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.21 14:18:26