当前位置: 首页 > 知识库问答 >
问题:

在颤动应用中,定位 S(版本 31 及更高版本)要求在创建“挂起的提示”时指定FLAG_IMMUTABLE或FLAG_MUTABLE之一

扈阳辉
2023-03-14

Installing build\app\outputs\flutter-apk\app.apk...
Debug service listening on ws://127.0.0.1:55138/iMdUmbZTaNc=/ws
Syncing files to device sdk gphone64 x86 64...
I/javaClass(18284): Calling to method: initService
I/javaClass(18284): start service invoked
I/javaClass(18284): Attempting to initialize service...
I/javaClass(18284): Service not bound, binding now....
I/javaClass(18284): Mapping method call to player item object
I/javaClass(18284): Firing up service. (onStartCommand)...
I/javaClass(18284): LocalBroadCastManager Received...
W/e.radio_tysa_f(18284): Accessing hidden method Landroid/media/AudioTrack;->getLatency()I (unsupported, reflection, allowed)
I/ExoPlayerImpl(18284): Init 398a550 [ExoPlayerLib/2.13.1] [emulator64_x86_64_arm64, sdk_gphone64_x86_64, Google, 32]
I/javaClass(18284): Pushing Event: flutter_radio_loading
I/javaClass(18284): onPlayerStateChanged: LOADING
D/AndroidRuntime(18284): Shutting down VM
E/AndroidRuntime(18284): FATAL EXCEPTION: main
E/AndroidRuntime(18284): Process: com.example.radio_tysa_fm, PID: 18284
E/AndroidRuntime(18284): java.lang.RuntimeException: Unable to start service me.sithiramunasinghe.flutter.flutter_radio_player.core.StreamingCore@ed87b05 with Intent { cmp=com.example.radio_tysa_fm/me.sithiramunasinghe.flutter.flutter_radio_player.core.StreamingCore (has extras) }: java.lang.IllegalArgumentException: com.example.radio_tysa_fm: Targeting S+ (version 31 and above) requires that one of FLAG_IMMUTABLE or FLAG_MUTABLE be specified when creating a PendingIntent.
E/AndroidRuntime(18284): 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.
E/AndroidRuntime(18284):    at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:4697)
E/AndroidRuntime(18284):    at android.app.ActivityThread.access$2000(ActivityThread.java:256)
E/AndroidRuntime(18284):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2128)
E/AndroidRuntime(18284):    at android.os.Handler.dispatchMessage(Handler.java:106)
E/AndroidRuntime(18284):    at android.os.Looper.loopOnce(Looper.java:201)
E/AndroidRuntime(18284):    at android.os.Looper.loop(Looper.java:288)
E/AndroidRuntime(18284):    at android.app.ActivityThread.main(ActivityThread.java:7842)
E/AndroidRuntime(18284):    at java.lang.reflect.Method.invoke(Native Method)
E/AndroidRuntime(18284):    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
E/AndroidRuntime(18284):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1003)
E/AndroidRuntime(18284): Caused by: java.lang.IllegalArgumentException: com.example.radio_tysa_fm: Targeting S+ (version 31 and above) requires that one of FLAG_IMMUTABLE or FLAG_MUTABLE be specified when creating a PendingIntent.
E/AndroidRuntime(18284): 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.
E/AndroidRuntime(18284):    at android.app.PendingIntent.checkFlags(PendingIntent.java:375)
E/AndroidRuntime(18284):    at android.app.PendingIntent.getBroadcastAsUser(PendingIntent.java:645)
E/AndroidRuntime(18284):    at android.app.PendingIntent.getBroadcast(PendingIntent.java:632)
E/AndroidRuntime(18284):    at com.google.android.exoplayer2.ui.PlayerNotificationManager.createBroadcastIntent(PlayerNotificationManager.java:1395)
E/AndroidRuntime(18284):    at com.google.android.exoplayer2.ui.PlayerNotificationManager.createPlaybackActions(PlayerNotificationManager.java:1351)
E/AndroidRuntime(18284):    at com.google.android.exoplayer2.ui.PlayerNotificationManager.<init>(PlayerNotificationManager.java:658)
E/AndroidRuntime(18284):    at com.google.android.exoplayer2.ui.PlayerNotificationManager.<init>(PlayerNotificationManager.java:568)
E/AndroidRuntime(18284):    at com.google.android.exoplayer2.ui.PlayerNotificationManager.createWithNotificationChannel(PlayerNotificationManager.java:521)
E/AndroidRuntime(18284):    at me.sithiramunasinghe.flutter.flutter_radio_player.core.StreamingCore.onStartCommand(StreamingCore.kt:248)
E/AndroidRuntime(18284):    at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:4679)
E/AndroidRuntime(18284):    ... 9 more
I/Process (18284): Sending signal. PID: 18284 SIG: 9
Lost connection to device.

共有2个答案

欧阳博超
2023-03-14

添加此内容以解决此问题:实现“androidx.work:工作运行时-ktx:2.8.0-alpha01”

杨景山
2023-03-14

错误消息和堆栈跟踪会准确地告诉您问题所在和位置。

com.google.android.exoplayer2.ui.PlayerNotificationManager.createBroadcastIntent(PlayerNotification Manager.java:1395)中

您需要将PendingIntent.FLAG_IMMUTABLEPendingIntent.FLAG_MUTABLE添加到对PendingIntent.getBroadcast()的调用中。

有关详细信息,请参阅https://developer.android.com/guide/components/intents-filters#DeclareMutabilityPendingIntent

 类似资料: