0

Can anybody help me please. I already have added FLAG_IMMUTABLE flag to all pending intents for supporting Android 12, but when try to call any API using retrofit on app start, app thorws below exception and crash.

Http Log

I/okhttp.OkHttpClient: --> GET https://api.covantex.com/v1/EnvironmentFlags
I/okhttp.OkHttpClient: --> END GET
I/okhttp.OkHttpClient: <-- HTTP FAILED: java.lang.IllegalArgumentException: com.covantex: Targeting S+ (version 31 and above) requires that one of FLAG_IMMUTABLE or FLAG_MUTABLE be specified when creating a PendingIntent.
I/okhttp.OkHttpClient: 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.
I/okhttp.OkHttpClient: <-- HTTP FAILED: java.lang.IllegalArgumentException: com.covantex: Targeting S+ (version 31 and above) requires that one of FLAG_IMMUTABLE or FLAG_MUTABLE be specified when creating a PendingIntent.
I/okhttp.OkHttpClient: 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.

Libraries for using APIs

implementation "com.google.code.gson:gson:2.9.0"
implementation "com.squareup.okhttp3:logging-interceptor:4.9.2"
implementation "com.squareup.retrofit2:retrofit:2.9.0"
implementation "com.squareup.retrofit2:converter-gson:2.9.0"
implementation "com.squareup.retrofit2:converter-scalars:2.9.0"
asissuthar
  • 2,078
  • 1
  • 15
  • 29

1 Answers1

0

Try like this: PendingIntent clickPendingIntent = PendingIntent.getActivity(this, 0, clickIntent, PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_IMMUTABLE);

Matt
  • 7,255
  • 2
  • 12
  • 34
Venky
  • 16
  • 1