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

使用Expo EAS构建时遇Android Manifest配置同步错误求助

Expo EAS构建配置同步失败:TypeError: androidManifest.manifest.hasOwnProperty is not a function

问题描述

使用Expo EAS构建项目时遭遇配置同步失败,报错信息为TypeError: [android.manifest]: withAndroidManifestBaseMod: androidManifest.manifest.hasOwnProperty is not a function。推测问题出在app.config.js配置中,已尝试修改配置文件、更新依赖,但问题持续一周仍未解决。

错误日志

expo:config-plugins:android:package Found package "com.sh411.CFlow" for type "debug" +0ms
expo:config-plugins:android:package Found package "com.sh411.CFlow" for type "main" +1ms
expo:config-plugins:android:package Found package "com.sh411.CFlow" for type "release" +0ms
android.dangerous: withAndroidExpoPlugins ➜ withPlugins ➜ withStaticPlugin ➜ withAndroidIcons ➜ withDangerousMod

- Config syncing
android.dangerous: withAndroidExpoPlugins ➜ withPlugins ➜ withStaticPlugin ➜ withGoogleServicesFile ➜ withDangerousMod

- Config syncing
android.dangerous: withSplashScreen ➜ withAndroidSplashScreen ➜ withPlugins ➜ withStaticPlugin ➜ withAndroidSplashDrawables ➜ withDangerousMod

- Config syncing
android.dangerous: withSplashScreen ➜ withAndroidSplashScreen ➜ withPlugins ➜ withStaticPlugin ➜ withAndroidSplashImages ➜ withDangerousMod

- Config syncing
android.dangerous: withFallback ➜ withPlugins ➜ withStaticPlugin ➜ withNotificationIcons ➜ withDangerousMod

- Config syncing
android.manifest: withDefaultBaseMods ➜ withAndroidBaseMods ➜ withGeneratedBaseMods ➜ withAndroidManifestBaseMod

- Config syncing
expo:config-plugins:base-mods mods.android.manifest: file path: /Users/sh/CFlowMobile/android/app/src/main/AndroidManifest.xml +83ms
android.manifest: withAndroidExpoPlugins ➜ withPlugins ➜ withStaticPlugin ➜ withAndroidIcons ➜ withAndroidManifestIcons ➜ withAndroidManifest

- Config syncing
**android.manifest: withAndroidExpoPlugins ➜ withPlugins ➜ withStaticPlugin ➜ withPermissions ➜ withAndroidManifest

- Config syncing
✖ Config sync failed**

TypeError: [android.manifest]: withAndroidManifestBaseMod: androidManifest.manifest.hasOwnProperty is not a function
TypeError: [android.manifest]: withAndroidManifestBaseMod: androidManifest.manifest.hasOwnProperty is not a function
at setAndroidPermissions (/Users/sh/CFlowMobile/node_modules/@expo/prebuild-config/node_modules/@expo/config-plugins/build/android/Permissions.js:123:33)

app.config.js配置代码

module.exports = {
  expo: {
    name: 'CFlow',
    slug: 'CFlow',
    version: '1.0.0',
    orientation: 'portrait',
    icon: './assets/icon.png',
    android: {
      package: 'com.sh411.CFlow',
      manifest: {
        permissions: ['CAMERA', 'READ_EXTERNAL_STORAGE'],
        usesCleartextTraffic: true,
        application: {
          activity: {
            'android:windowSoftInputMode': 'adjustPan',
          },
        },
      },
    },
    ios: {
      bundleIdentifier: 'com.sh411.CFlow',
    },
    androidStatusBar: {
      backgroundColor: '#ffffff',
      barStyle: 'dark-content',
      translucent: true,
    },
    splash: {
      image: './assets/splash.png',
      resizeMode: 'contain',
      backgroundColor: '#ffffff',
    },
    mods: {
      android: {
        manifest: {
          permissions: ['CAMERA', 'READ_EXTERNAL_STORAGE'],
          usesCleartextTraffic: true,
          application: {
            activity: {
              'android:windowSoftInputMode': 'adjustPan',
            },
          },
        },
      },
      ios: {
        infoPlist: {
          NSCameraUsageDescription: 'This app uses the camera to take photos',
          NSPhotoLibraryUsageDescription: 'This app needs access to your photo library',
        },
      },
    },
    extra: {
      eas: {
        projectId: 'b1c7ca55-d671-4f7b-a550-xxx',
      },
    },
  },
};

解决方案

问题根因

错误源于mods.android.manifest的配置覆盖了Expo内部生成的标准Android Manifest对象结构,导致androidManifest.manifest不再是合法的JavaScript对象,无法调用hasOwnProperty方法。同时android.manifest.application.activity定义为单个对象不符合Android Manifest的数组结构要求。

修复步骤

  1. 删除重复的mods.android.manifest配置
    保留android.manifest下的配置即可,移除mods.android.manifest整个节点,避免配置冲突。

  2. 修正activity节点为数组结构
    将android.manifest.application.activity从单个对象改为数组,因为Android Manifest中activity是可多实例的节点,Expo要求用数组定义。

  3. 清理缓存并重新构建
    执行以下命令清理旧构建文件,重新触发配置同步:

    npx expo prebuild --clean
    

    之后重新执行EAS构建命令。

修改后的app.config.js

module.exports = {
  expo: {
    name: 'CFlow',
    slug: 'CFlow',
    version: '1.0.0',
    orientation: 'portrait',
    icon: './assets/icon.png',
    android: {
      package: 'com.sh411.CFlow',
      manifest: {
        permissions: ['CAMERA', 'READ_EXTERNAL_STORAGE'],
        usesCleartextTraffic: true,
        application: {
          activity: [
            {
              'android:windowSoftInputMode': 'adjustPan',
            },
          ],
        },
      },
    },
    ios: {
      bundleIdentifier: 'com.sh411.CFlow',
    },
    androidStatusBar: {
      backgroundColor: '#ffffff',
      barStyle: 'dark-content',
      translucent: true,
    },
    splash: {
      image: './assets/splash.png',
      resizeMode: 'contain',
      backgroundColor: '#ffffff',
    },
    mods: {
      ios: {
        infoPlist: {
          NSCameraUsageDescription: 'This app uses the camera to take photos',
          NSPhotoLibraryUsageDescription: 'This app needs access to your photo library',
        },
      },
    },
    extra: {
      eas: {
        projectId: 'b1c7ca55-d671-4f7b-a550-xxx',
      },
    },
  },
};

内容的提问来源于stack exchange,提问作者Hakmta

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.25 07:09:55