当前位置: 首页 > 知识库问答 >
问题:

针对S(版本31及以上)需要FLAG_IMMUTABLE或FLAG_MUTABLE

商柏
2023-03-14

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

implementation 'androidx.work:work-runtime-ktx:2.7.1'

我更新了

implementation 'com.google.firebase:firebase-messaging-ktx:23.0.0'

firebase消息库

我在我的项目中使用了待处理的意图,就像这样

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

错误:

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 to be used with inline replies or bubbles.
    at android.app.PendingIntent.checkFlags(PendingIntent.java:375)
    at android.app.PendingIntent.getActivityAsUser(PendingIntent.java:458)
    at android.app.PendingIntent.getActivity(PendingIntent.java:444)
    at android.app.PendingIntent.getActivity(PendingIntent.java:408)
    at com.chuckerteam.chucker.internal.support.NotificationHelper$transactionsScreenIntent$2.invoke(NotificationHelper.kt:47)
    at com.chuckerteam.chucker.internal.support.NotificationHelper$transactionsScreenIntent$2.invoke(NotificationHelper.kt:19)
    at kotlin.SynchronizedLazyImpl.getValue(LazyJVM.kt:74)
    at com.chuckerteam.chucker.internal.support.NotificationHelper.getTransactionsScreenIntent(Unknown Source:2)
    at com.chuckerteam.chucker.internal.support.NotificationHelper.show(NotificationHelper.kt:101)
    at com.chuckerteam.chucker.api.ChuckerCollector.onRequestSent$com_github_ChuckerTeam_Chucker_library(ChuckerCollector.kt:65)
    at com.chuckerteam.chucker.api.ChuckerInterceptor.intercept(ChuckerInterceptor.kt:111)
    at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
    at com.android.core.helpers.interceptor.HeadersInterceptor.intercept(HeadersInterceptor.kt:41)
    at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
    at com.android.core.helpers.AuthInterceptor.intercept(AuthInterceptor.kt:39)
    at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
    at okhttp3.internal.connection.RealCall.getResponseWithInterceptorChain$okhttp(RealCall.kt:201)
    at okhttp3.internal.connection.RealCall$AsyncCall.run(RealCall.kt:517)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
    at java.lang.Thread.run(Thread.java:920)
E/WebEngage: App has crashed
    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 to be used with inline replies or bubbles.

共有1个答案

蒋寒
2023-03-14

我终于找到了问题,我有卡盘库,我将其更新到最新版本,并修复了

 类似资料: