gpt4 book ai didi

android - 定位 S+(版本 10000 及更高版本)要求在创建 PendingIntent 时指定 FLAG_IMMUTABLE 或 FLAG_MUTABLE 之一

转载 作者:行者123 更新时间:2023-12-04 23:35:39 26 4
gpt4 key购买 nike

尝试将我的应用程序更新到 Android S 并遇到标题/错误所说的一些问题。我得到错误

Targeting S+ (version 10000 and above) requires that one ofFLAG_IMMUTABLE or FLAG_MUTABLE be specified when creating aPendingIntent.Strongly consider using FLAG_IMMUTABLE, only use FLAG_MUTABLE if some functionality depends on the PendingIntent being mutable, e.g. ifit needs to be used with inline replies or bubbles.


我的代码中只有 1 个 PendingIntent 用于通知,我添加了标志
PendingIntent.getActivity(
mContext,
0 /* Request code */,
intentOptional.get(),
PendingIntent.FLAG_IMMUTABLE
)
阅读 Google 的文档,这应该是我在 Android S 中进行此安全更新所需的全部内容。我确实在这里找到了几个月前的帖子,询问了类似的内容,有人说要添加 WorkManager https://stackoverflow.com/a/67181567/4219444即使您不使用它,也可以进入项目。所以我加了
def work_version = "2.7.0-alpha04" 
implementation "androidx.work:work-runtime-ktx:$work_version"
这根本没有帮助,因为我仍然收到错误。有谁知道这是否是 Android S 升级的常见问题,或者它是否也检查库?卡住了,因为应用程序一直在崩溃,不知道该怎么办。
我创建了一个没有任何库的应用程序,并使用了相同的 PendingIntent,并且能够运行一个带有待处理 Intent 的基本 hello world 应用程序。我从我试图编译的项目中收到的完整错误是:

Targeting S+ (version 10000 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.google.android.gms.internal.gtm.zzbv.zzfe(Unknown Source:52)at com.google.android.gms.internal.gtm.zzbv.cancel(Unknown Source:54)at com.google.android.gms.internal.gtm.zzbv.zzaw(Unknown Source:4)at com.google.android.gms.internal.gtm.zzan.zzag(Unknown Source:7)at com.google.android.gms.internal.gtm.zzap.(Unknown Source:67)at com.google.android.gms.internal.gtm.zzap.zzc(Unknown Source:82)at com.google.android.gms.analytics.GoogleAnalytics.getInstance(Unknown Source:15)at di.internal.module.ApplicationModule.providesGoogleAnalyticsLogger$app_developmentDebug(ApplicationModule.kt:339)at di.internal.module.ApplicationModule_ProvidesGoogleAnalyticsLogger$app_developmentDebugFactory.providesGoogleAnalyticsLogger$app_developmentDebug(ApplicationModule_ProvidesGoogleAnalyticsLogger$app_developmentDebugFactory.java:47)at di.internal.module.ApplicationModule_ProvidesGoogleAnalyticsLogger$app_developmentDebugFactory.get(ApplicationModule_ProvidesGoogleAnalyticsLogger$app_developmentDebugFactory.java:36)at di.internal.module.ApplicationModule_ProvidesGoogleAnalyticsLogger$app_developmentDebugFactory.get(ApplicationModule_ProvidesGoogleAnalyticsLogger$app_developmentDebugFactory.java:11)at dagger.internal.DoubleCheck.get(DoubleCheck.java:47)at di.internal.module.ApplicationModule_ProvidesMultiAnalyticsLogger$app_developmentDebugFactory.get(ApplicationModule_ProvidesMultiAnalyticsLogger$app_developmentDebugFactory.java:35)at di.internal.module.ApplicationModule_ProvidesMultiAnalyticsLogger$app_developmentDebugFactory.get(ApplicationModule_ProvidesMultiAnalyticsLogger$app_developmentDebugFactory.java:10)at dagger.internal.DoubleCheck.get(DoubleCheck.java:47)at di.internal.component.DaggerIProdApplicationComponent.injectChApplication(DaggerIProdApplicationComponent.java:941)2021-07-02 11:18:17.611 22561-22561/com.chrobinson.navispherecarrier.dev E/AndroidRuntime: at di.internal.component.DaggerIProdApplicationComponent.inject(DaggerIProdApplicationComponent.java:876)at com.chrobinson.navispherecarrier.ChApplication.onCreate(ChApplication.kt:90)at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1211)at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6682)

最佳答案

它通过添加来解决

implementation 'androidx.work:work-runtime:2.7.0-alpha05'
在我的毕业典礼上。 (您可以添加此库的最新发布版本)
似乎这是工作管理器中的错误。检查版本 2.7.0-alpha02 中的错误修复
https://developer.android.com/jetpack/androidx/releases/work#2.7.0-alpha02

关于android - 定位 S+(版本 10000 及更高版本)要求在创建 PendingIntent 时指定 FLAG_IMMUTABLE 或 FLAG_MUTABLE 之一,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68228666/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com