小编Mah*_*eei的帖子

以 S+(版本 31 及更高版本)为目标需要 FLAG_IMMUTABLE 或 FLAG_MUTABLE 之一

当我在 android 12 中启动我的应用程序时,它崩溃了并且给了我这个错误,我的项目已经有这个依赖项

implementation 'androidx.work:work-runtime-ktx:2.7.1'
Run Code Online (Sandbox Code Playgroud)

我更新了

implementation 'com.google.firebase:firebase-messaging-ktx:23.0.0'
Run Code Online (Sandbox Code Playgroud)

firebase 消息传递库

我在我的项目中使用了待定意图,如下所示

    val pendingIntent = PendingIntent.getActivity(
        applicationContext,
        0,
        intent,
        PendingIntent.FLAG_IMMUTABLE or PendingIntent.FLAG_UPDATE_CURRENT // setting the mutability flag
    )
Run Code Online (Sandbox Code Playgroud)

错误 :

E/AndroidRuntime: FATAL EXCEPTION: OkHttp Dispatcher
Process: com.internal, PID: 11866
java.lang.IllegalArgumentException: com.internal: 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 …
Run Code Online (Sandbox Code Playgroud)

java android kotlin android-studio

7
推荐指数
1
解决办法
5779
查看次数

标签 统计

android ×1

android-studio ×1

java ×1

kotlin ×1