0

I'm trying to change targeting version to Android 12 (S). But I have an error

java.lang.IllegalArgumentException: : 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.

The code, that producing this error is:

return regRestClient.getToken(idRef)
            .onErrorResumeNext(
                    regRestClient.registerDevice(idRef, Build.PRODUCT, Build.MODEL)
                    .flatMap(response -> regRestClient.getToken(idRef))
            )
            .map((result) ->
                    new TokenResult(result.getToken())
            )
            .doOnError(error -> provideActivityToConsumer(activity -> onRegFailed(activity, error)))
            .onErrorReturn(throwable -> new TokenResult(null));

Get device token query:

@GET("device/{deviceId}")
@Headers( {Api.HEADER, Api.AUTH})
Single<TokenResult> getToken(@Path("idd") IdRef id);

I don't understand, it seems that RxJava libraries or retrofit libraries have some PendingIntent functionality, but I don't understand which exactly library.

my libraries:

 implementation 'io.reactivex.rxjava2:rxandroid:2.1.1'
 implementation 'io.reactivex.rxjava2:rxjava:2.2.18'
 implementation 'com.squareup.retrofit2:retrofit:2.9.0'
 implementation 'com.squareup.retrofit2:converter-gson:2.9.0'
 implementation 'com.squareup.retrofit2:adapter-rxjava2:2.9.0'

Please help!

Vladimir Fisher
  • 3,090
  • 2
  • 17
  • 23
  • 2
    Neither RxJava nor Retrofit are Android-specific libraries. They do not contain Android-specific code, such as `PendingIntent`. `io.reactivex.rxjava2:rxandroid` *is* Android-specific, but I would be surprised if it uses a `PendingIntent`. Perhaps something being called by your RxJava chain, such as `getToken()` or `provideActivityToConsumer()`, is creating a `PendingIntent`. – CommonsWare Nov 29 '21 at 13:22

2 Answers2

4

In my case, I used library - 'com.readystatesoftware.chuck:library:..*'. And this library contains itself notification and its notification is not working for Android 12 (S).

If you also used this library for debugging, just remove it and try again.

Dharman
  • 30,962
  • 25
  • 85
  • 135
AbrusDev
  • 41
  • 1
  • 2
0

Just add this dependency to your app module and everything will be good by some reason.

implementation 'androidx.work:work-runtime-ktx:2.7.1'

There is source of information: https://developer.android.com/jetpack/androidx/releases/work#version_27_2