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

Android编译SDK为31时调用SnapCreativeKitApi.send抛出IllegalArgumentException

问题背景

当Android项目使用31及以上版本编译SDK时,调用SnapCreativeKitApi.send方法会抛出IllegalArgumentException异常。目前Snapchat官方发布的最新SDK版本为v1.13.0,尚未修复该问题。

异常堆栈信息
IllegalArgumentException: com.test.test: Targeting S+ (version 31 and above) 
requires that one of FLAG_IMMUTABLE 
or FLAG_MUTABLE be specified when creating a PendingIntent.
Strongly consider using FLAG_IMMUTABLE, only use FLAG_MUTABLE if some functionality depends on the PendingIntent being mutable, e.g. if it needs to be used with inline replies or bubbles.
    at android.app.PendingIntent.checkFlags(PendingIntent.java:375)
    at android.app.PendingIntent.getBroadcastAsUser(PendingIntent.java:645)
    at android.app.PendingIntent.getBroadcast(PendingIntent.java:632)
    at com.snapchat.kit.sdk.creative.api.SnapCreativeKitApi.sendWithCompletionHandler(SourceFile:151)
    at com.snapchat.kit.sdk.creative.api.SnapCreativeKitApi.send(SourceFile:100)
修复进度说明

目前Snapchat官方暂未对外公布该问题修复版本的具体发布时间。该问题属于Android 12版本适配的必填兼容性改动,优先级较高,大概率会在后续小版本更新中优先上线修复。

临时规避方案
  • 临时将项目的compileSdk与targetSdk版本降级至30,可避开该PendingIntent检查逻辑,不影响相关接口正常调用
  • 若业务必须使用31及以上版本编译,可通过反射修改SDK内部创建PendingIntent时传入的flag参数,在不需要PendingIntent可变的场景下优先添加FLAG_IMMUTABLE标识
  • 若业务依赖PendingIntent可变能力,添加FLAG_MUTABLE标识即可正常运行

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.09.23 17:54:01