目标定向至 S+(版本 31 及以上)需要 FLAG_IMMUTABLE 或 FLAG_MUTABLE 中的一个。

7
当我在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
请问您能否发布完整的崩溃日志?崩溃是否指向您自己的代码还是第三方库的代码? - Mayur Gajra
更新所有的依赖项。 - Manjeet deswal
我更新了问题,你可以看到完整的崩溃日志,谢谢。 - Mahdi Zareei
1个回答

13
我终于找到了问题所在, 我之前使用的Chucker库,我将它更新到最新版本后问题得以修复。

Chucker与这个问题有什么关系?但它是正确的。 - milad salimi
检查版本3.5.1 https://github.com/ChuckerTeam/chucker/releases - Mahmoud Omara
因为 Chucker 没有在旧版本中设置显示通知的标志。 - Mahdi Zareei
1
我曾经遇到过同样的问题。我使用了Chuck(https://github.com/jgilfelt/chuck)。我将Chuck移除并添加了Chocker到一个个人项目中,现在它可以正常工作了(https://github.com/ChuckerTeam/chucker)。 - Pablo S. Campos

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接