Flutter集成jitsi_meet 4.0.0在Android API33崩溃问题求助
解决Flutter集成jitsi_meet在Android API 33上的崩溃问题
问题根源
你遇到的崩溃是因为Android 12(API Level 31)及以上版本要求创建PendingIntent时必须指定FLAG_IMMUTABLE或FLAG_MUTABLE标记。虽然你没有直接使用PendingIntent和Broadcast,但jitsi_meet: ^4.0.0的底层依赖(如Jitsi SDK)或关联库存在未适配该规则的代码,导致API 33设备崩溃。
解决方案
1. 升级jitsi_meet到兼容Android 12+的版本
检查pub.dev上jitsi_meet的最新稳定版,替换pubspec.yaml中的依赖:
jitsi_meet: ^x.x.x # 替换为最新支持Android 12+的版本
执行flutter pub get更新依赖后重新编译测试。
2. 强制升级AndroidX Work库到更高版本
你之前集成的androidx.work:work-runtime-ktx:2.7.0仍存在适配问题,需升级到2.8.0及以上版本。在android/app/build.gradle的dependencies块中修改:
implementation 'androidx.work:work-runtime-ktx:2.8.1' // 推荐使用最新稳定版
同时在android/build.gradle的allprojects块中添加强制依赖规则,确保所有模块统一使用该版本:
allprojects { repositories { // ... 其他仓库配置 } configurations.all { resolutionStrategy { force 'androidx.work:work-runtime-ktx:2.8.1' } } }
3. 排查并升级其他依赖库
若上述操作无效,执行flutter pub deps查看项目完整依赖树,找出可能存在旧版PendingIntent创建逻辑的第三方库,逐一升级到适配Android 12+的版本。
4. 本地修改jitsi_meet源码(备选方案)
如果无法通过升级依赖解决,可将jitsi_meet作为本地依赖引入项目,手动修改其Android端代码中创建PendingIntent的部分:
找到创建PendingIntent的代码位置,添加FLAG_IMMUTABLE标记(非动态广播场景优先使用):
// 修改前 PendingIntent pendingIntent = PendingIntent.getBroadcast(context, 0, intent, 0); // 修改后 PendingIntent pendingIntent = PendingIntent.getBroadcast(context, 0, intent, PendingIntent.FLAG_IMMUTABLE);
内容的提问来源于stack exchange,提问作者Muhammad Asad
相关产品推荐
相关产品推荐

