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

Flutter集成Razorpay首次启动崩溃:IntentReceiver泄漏问题求助

解决Razorpay CheckoutActivity IntentReceiver泄漏崩溃问题

问题背景

升级Razorpay Android SDK到1.6.26并更新ProGuard规则后,Android端出现以下崩溃,iOS端运行正常:

E/ActivityThread: Activity com.razorpay.CheckoutActivity has leaked IntentReceiver com.razorpay.b__J_@837b24 that was originally registered here. Are you missing a call to unregisterReceiver()?
android.app.IntentReceiverLeaked: Activity com.razorpay.CheckoutActivity has leaked IntentReceiver com.razorpay.b__J_@837b24 that was originally registered here. Are you missing a call to unregisterReceiver()?

解决方案

  • 验证ProGuard规则完整性
    确保ProGuard配置包含以下规则,避免SDK内部类被混淆导致生命周期异常:

    -keep class com.razorpay.** {*;}
    -dontwarn com.razorpay.**
    -keepattributes *Annotation*
    -keepattributes Signature
    

    清理并重新构建项目,确保混淆规则生效。

  • 修正Activity配置
    在AndroidManifest.xml中检查CheckoutActivity的声明,添加configChanges属性避免因配置变更重建Activity,同时设置合理的启动模式:

    <activity
        android:name="com.razorpay.CheckoutActivity"
        android:configChanges="orientation|screenSize|keyboardHidden"
        android:launchMode="singleTop" />
    
  • 手动释放SDK资源
    在宿主Activity的onDestroy()方法中,调用Razorpay实例的清理方法,确保SDK内部广播接收器被正确注销:

    @Override
    protected void onDestroy() {
        super.onDestroy();
        if (razorpay != null) {
            razorpay.clear();
        }
    }
    
  • 切换SDK版本
    1.6.26版本可能存在已知bug,尝试降级到前一个稳定版本(如1.6.25)或升级到最新稳定版,验证崩溃是否消失。

  • 排查自定义广播逻辑
    如果你的代码中注册了与Razorpay相关的自定义广播接收器,务必在Activity销毁时调用unregisterReceiver()完成注销,避免交叉泄漏。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.25 20:17:14