ghenry22 / cordova-plugin-music-controls2

A Cordova plugin displaying music controls in notifications (cordova-plugin-music-controls)
MIT License
59 stars 60 forks source link

Many crashes in latest android devices #82

Closed merbin2012 closed 1 year ago

merbin2012 commented 2 years ago

In Android 11 and Android 12 many crashes, please fix it. 1658051264911

1658051475448

bikubi commented 2 years ago

Could you provide more information for the exceptions? The traces / error messages in your screenshot are truncated.

The SecurityException looks like this problem: https://stackoverflow.com/questions/52382710/permission-denial-startforeground-requires-android-permission-foreground-servic

badursun commented 2 years ago

I think I'm here because of the same mistake. When I debug my error, I get the following output as an error. I guess an error occurs with android API 31 and above.

2022-11-02 19:13:45.160 28449-28714/tr.com.testfm.app E/AndroidRuntime: FATAL EXCEPTION: pool-2-thread-2 Process: tr.com.testfm.app, PID: 28449 java.lang.IllegalArgumentException: tr.com.testfm.app: 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. at android.app.PendingIntent.checkFlags(PendingIntent.java:375) at android.app.PendingIntent.getActivityAsUser(PendingIntent.java:458) at android.app.PendingIntent.getActivity(PendingIntent.java:444) at android.app.PendingIntent.getActivity(PendingIntent.java:408) at com.homerours.musiccontrols.MusicControlsNotification.createBuilder(MusicControlsNotification.java:219) at com.homerours.musiccontrols.MusicControlsNotification.updateNotification(MusicControlsNotification.java:76) at com.homerours.musiccontrols.MusicControls$2.run(MusicControls.java:155) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641) at java.lang.Thread.run(Thread.java:920) 2022-11-02 19:13:45.236 28449-28449/tr.com.testfm.app D/CordovaActivity: Paused the activity. 2022-11-02 19:13:45.336 28449-28449/tr.com.testfm.app D/CordovaActivity: Stopped the activity. 2022-11-02 19:13:45.347 28449-28449/tr.com.testfm.app D/CordovaActivity: CordovaActivity.onDestroy()

ghenry22 commented 1 year ago

Looks like PR #78 fixes this, I will test and merge it if all looks good

badursun commented 1 year ago

yes, as in #78, it is enough to update the relevant java files and you can get signed AAB. In current version you can get unsigned APK but not signed AAB.

ghenry22 commented 1 year ago

@badursun you can give the dev branch a try if you like, I've merged PR #78 into it and it now builds and runs without issue even targetting API 33. I don't have my physical test device with me at the moment so I won't merge it to master and release until I can test fully with that next week.

you can install the branch with: cordova plugin add https://github.com/ghenry22/cordova-plugin-music-controls2#dev

merbin2012 commented 1 year ago

It is the error related to pending intent, which I have changed in the source code.

badursun commented 1 year ago

@badursun you can give the dev branch a try if you like, I've merged PR #78 into it and it now builds and runs without issue even targetting API 33. I don't have my physical test device with me at the moment so I won't merge it to master and release until I can test fully with that next week.

you can install the branch with: cordova plugin add https://github.com/ghenry22/cordova-plugin-music-controls2#dev

I'll recompile the project soon, then I can test it. You should definitely try to get a signed AAB file just when testing. Because it compiles fine in unsigned APK file. Thank you

ghenry22 commented 1 year ago

should be fixed in version 3.0.7 which is merged to master and pushed to npmjs.

No issue with production builds and signed aab, no crashes on device or emulator.