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

Expo集成Notifee报错:Notifee原生模块未找到

Expo集成Notifee报错的解决办法

问题排查与修复步骤

1. 修正Android包名格式

你的app.json里Android包名"package": "GymTracker.app"不符合Android规范,必须使用反向域名格式(比如com.gymtracker.app)。包名错误会导致Native模块无法正常注册,修改后重新执行expo prebuild:

"android": {
  "adaptiveIcon": {
    "foregroundImage": "./assets/adaptive-icon.png",
    "backgroundColor": "#FFFFFF"
  },
  "package": "com.gymtracker.app"
}

2. 调整版本兼容性

你使用的Expo 45(对应RN 0.68.2)和Notifee 5.5.0存在版本兼容问题,Notifee 5.x要求Expo版本至少为46+。建议降级Notifee到适配Expo 45的版本:

expo install @notifee/react-native@4.1.0

3. 清理缓存并重新构建

缓存残留可能导致模块加载异常,按以下步骤操作:

  • 清除项目缓存:expo r -c
  • 删除自动生成的原生目录:rm -rf ios android
  • 重新预构建:expo prebuild
  • 重启项目:expo start --clear

4. 确认主组件注册正确

"Invariant Violation: 'main' has not been registered"一般是入口文件注册问题,检查index.js是否包含正确的注册代码:

import { AppRegistry } from 'react-native';
import App from './App';
import { name as appName } from './app.json';

AppRegistry.registerComponent(appName, () => App);

5. 验证插件配置

你当前app.json的plugins配置是正确的,无需额外调整:

"plugins": ["@notifee/react-native"]

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.24 12:03:22