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

如何在本地开发中禁用FullStory以解决Android构建失败问题?

在本地开发环境禁用FullStory的方案

首先引用FullStory官网说明:

FullStory React Native插件目前不兼容Metro服务器或未ejected的Expo应用。

已ejected的Expo应用完全支持。如果要在本地开发中使用Metro服务器,建议为此类构建禁用FullStory。

以下是几种可行的禁用方式:

1. 通过环境变量控制

  • 启动Metro时注入禁用标识:
    FULLSTORY_DISABLE=true npx react-native start
    
  • 在代码中根据环境变量判断是否初始化FullStory:
    import FullStory from '@fullstory/react-native';
    
    if (!process.env.FULLSTORY_DISABLE) {
      FullStory.init({ orgId: '你的组织ID' });
    }
    

2. 针对Android构建变体配置

  • 修改android/app/build.gradle,为debug构建清空FullStory的组织ID:
    android {
      buildTypes {
        debug {
          resValue "string", "fullstory_org_id", ""
        }
        release {
          resValue "string", "fullstory_org_id", "你的组织ID"
        }
      }
    }
    
  • 代码中根据组织ID是否为空决定是否初始化:
    import { NativeModules } from 'react-native';
    import FullStory from '@fullstory/react-native';
    
    const orgId = NativeModules.FullStory?.getOrgId() || '';
    if (orgId) {
      FullStory.init({ orgId });
    }
    

3. Expo ejected项目的配置调整

  • 在app.config.js中根据开发环境移除FullStory插件:
    export default ({ config }) => {
      if (process.env.NODE_ENV === 'development') {
        config.plugins = config.plugins?.filter(p => !p.includes('@fullstory/react-native'));
      }
      return config;
    };
    

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.03 19:55:16