11

Please help me to sort out the problem. I give a link to the git. https://github.com/Vasajj/radio_tysa_fm.git something is wrong with PendingIntent, with package:flutter_radio_player On android 8 all is fine

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.
David Wasser
  • 93,459
  • 16
  • 209
  • 274
Vasyl
  • 154
  • 1
  • 1
  • 9
  • 1
    Does this answer your question? [How to resolve "Missing PendingIntent mutability flag" lint warning in android api 30+?](https://stackoverflow.com/questions/67045607/how-to-resolve-missing-pendingintent-mutability-flag-lint-warning-in-android-a) – Nikhil Jain Mar 27 '22 at 14:00
  • Did you resolved this issue? I am too facing in flutter app. – Nicks Apr 06 '22 at 11:07
  • @NikhilJain All advisers give information taken from the documentation, but it feels like no one understands how to use this information. Where to write the code, what file to create, etc. Advice about implementation "androidx.work:work-runtime-ktx:$work_version" did, but does not help.. And I don't know what to do with this "val updatedPendingIntent = PendingIntent.getActivity( applicationContext, NOTIFICATION_REQUEST_CODE, updatedIntent, PendingIntent.FLAG_IMMUTABLE or PendingIntent.FLAG_UPDATE_CURRENT // setting the mutability flag )" – Vasyl Apr 10 '22 at 12:22
  • @Vasyl Are you using any dependency in pubspec.yaml which is causing this issue? Because I see from logs that your app is using exoplayer, if not used externally in flutter code then internally. Please check if you're using the latest dependencies in your flutter project. – Nikhil Jain Apr 10 '22 at 14:00
  • @Vasyl from github code I see you were using FlutterRadioPlayer, you can check this issue already reported for this library. Hope this helps. https://github.com/Sithira/FlutterRadioPlayer/issues/61 – Nikhil Jain Apr 10 '22 at 14:06
  • @NikhilJain yes i am using the package. Already more than a month ago I contacted the developers of the package .. At first they said that they would quickly make changes. But for some reason everything was delayed – Vasyl Apr 11 '22 at 19:35

3 Answers3

5

If your error message also includes these packages androidx.work.impl.utils it is plausible that your dependencies are outdated and not compatible with android runtime 31.

Update the androidx.work.work-runtime-ktx dependencies to fix the problem:

in app.gradle

implementation 'androidx.work:work-runtime-ktx:2.8.0-alpha01'

Paul Weber
  • 6,518
  • 3
  • 43
  • 52
1

The error message and stack trace tell you exactly what the problem is and where.

In com.google.android.exoplayer2.ui.PlayerNotificationManager.createBroadcastIntent(PlayerNotificationManager.java:1395)

you need to add either PendingIntent.FLAG_IMMUTABLE or PendingIntent.FLAG_MUTABLE to the call to PendingIntent.getBroadcast().

For more information see https://developer.android.com/guide/components/intents-filters#DeclareMutabilityPendingIntent

David Wasser
  • 93,459
  • 16
  • 209
  • 274
  • I've attached a screenshot that I added Missing PendingIntent mutability flag. Or do I still need to declare it in code? – Vasyl Mar 29 '22 at 08:48
  • I don't understand your comment. I don't see any screenshots that you added anything. You need to add the flags to your code that creates the `PendingIntent`s. – David Wasser Mar 29 '22 at 09:26
  • It's clear. But from the documentation I've read, I can't figure out where to add and what code. Yes I'm new at this :-( – Vasyl Mar 31 '22 at 11:40
0

In flutter adding this in my android/build.gradle fixed the issue for me

dependencies block

implementation 'androidx.work:work-runtime-ktx:2.8.1' // add this


dependencies {
 implementation"org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
 implementation 'androidx.work:work-runtime-ktx:2.8.1'
}
Apoorv Pandey
  • 2,118
  • 2
  • 11
  • 13