3

After updating targetsdk version to 31, the app is giving an error on pending intents. I have updated all the pending intents and then run the app. But the app is now crashing with this error

Caused by: java.lang.IllegalArgumentException: fm.iono.p953: 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.

But the line that the app crashes is the following:

val gmsTracker = GoogleAnalytics.getInstance(context).newTracker(gmsId)

see the screenshot below. I have highlighted the line with blue color where the app crashes. And from the logcat you can see the error. Not sure why the app is crashing on the line where no pending intent is available :)

enter image description here

Any help will be appreciated

Kishan Solanki
  • 13,761
  • 4
  • 85
  • 82
  • Do you have work manager in your build.gradle? If so, check this out: https://stackoverflow.com/questions/68228666/targeting-s-version-10000-and-above-requires-that-one-of-flag-immutable-or-fl – David Wasser Aug 26 '22 at 14:40
  • @DavidWasser I have already checked that answer before posting this question :) I am not using work manager on my project. – Kishan Solanki Aug 26 '22 at 14:47

1 Answers1

3

Make sure you are on the latest version of the Google Analytics dependency. It apparently is setting up that PendingIntent, and only the developers of Google Analytics can change that behavior.

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491