当我在 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)