目标S+(版本10000及以上)要求在创建PendingIntent时指定FLAG_IMMUTABLE或FLAG_MUTABLE之一。强烈建议使用FLAG_IMMUTABLE,仅在某些功能依赖于PendingIntent可变性的情况下使用FLAG_MUTABLE,例如,如果需要与内联回复或气泡一起使用。
我的代码中只有1个用于通知的PendingIntent,并添加了Flag。
PendingIntent.getActivity(
mContext,
0 /* Request code */,
intentOptional.get(),
PendingIntent.FLAG_IMMUTABLE
)
阅读 Google 的文档,这应该是我在 Android S 安全更新中所需要的全部内容。我在这里找到了一个几个月前的帖子,询问类似的问题,有人建议将 WorkManager https://dev59.com/Y1EG5IYBdhLWcg3wX7z1#67181567 添加到项目中,即使您不使用它。所以我添加了。
def work_version = "2.7.0-alpha04"
implementation "androidx.work:work-runtime-ktx:$work_version"
这并没有帮助我解决错误。有人知道这个Android S升级的常见问题吗?或者它是否也检查库?应用程序一直崩溃,不知道该怎么办。
我创建了一个没有任何库的应用程序,并使用相同的PendingIntent运行了一个基本的Hello World应用程序。我正在尝试编译的项目给出的完整错误是:
目标为S+(版本10000及以上)时,创建PendingIntent时需要指定FLAG_IMMUTABLE或FLAG_MUTABLE之一。强烈建议使用FLAG_IMMUTABLE,仅在某些功能依赖于PendingIntent可变性的情况下使用FLAG_MUTABLE,例如,如果需要与内联回复或气泡一起使用。
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)
com.google.android.gms.analytics.GoogleAnalytics.getInstance
-- 你正在使用Google Analytics吗? - CommonsWaretargetSdkVersion
升级到31
时,你将需要升级此依赖项(以及其他可能的依赖项)。 - CommonsWarecom.google.android.gms:play-services-analytics
设置为17.0.0,文档上也只有这一个版本。也许现在是时候完全移除Google Analytics并完全使用Firebase了。 - Adam Gardner