0

我正在尝试将目标版本更改为 Android 12 (S)。但我有一个错误

java.lang.IllegalArgumentException: : Targeting S+ (version 31 and above) requires that one of FLAG_IMMUTABLE or FLAG_MUTABLE be specified when creating a PendingIntent.

强烈考虑使用 FLAG_IMMUTABLE,仅当某些功能依赖于 PendingIntent 是可变的时才使用 FLAG_MUTABLE,例如,如果它需要与内联回复或气泡一起使用。

产生此错误的代码是:

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/{deviceId}")
@Headers( {Api.HEADER, Api.AUTH})
Single<TokenResult> getToken(@Path("idd") IdRef id);

我不明白,似乎 RxJava 库或改造库有一些 PendingIntent 功能,但我不明白究竟是哪个库。

我的图书馆:

 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'

请帮忙!

4

2 回答 2

2

就我而言,我使用了库 - 'com.readystatesoftware.chuck:library: .*'。这个库包含自己的通知,它的通知不适用于 Android 12 (S)。

如果您还使用此库进行调试,只需将其删除并重试。

于 2021-12-25T12:50:54.353 回答
0

只需将此依赖项添加到您的应用程序模块中,由于某种原因一切都会好起来的。

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

有资料来源:https ://developer.android.com/jetpack/androidx/releases/work#version_27_2

于 2021-11-29T14:13:44.890 回答