X-SLAYER / flutter_overlay_window

Flutter plugin for displaying flutter app over other apps on the screen
https://pub.dev/packages/flutter_overlay_window
MIT License
109 stars 114 forks source link

Android API30 crashes with a java.lang.IllegalArgumentException #14

Closed kmemo closed 6 months ago

kmemo commented 2 years ago

Testing flutter_overlay_window plugin on emulated Android 30 crashes with a java.lang.IllegalArgumentException (Compiled with SDK 31; Emulater version is 31.2.10)

E/AndroidRuntime(31320): java.lang.RuntimeException: Unable to create service flutter.overlay.window.flutter_overlay_window.OverlayService: java.lang.IllegalArgumentException: home.project.demo_overlay_window: Targeting S+ (version 10000 and above) requires that one of FLAG_IMMUTABLE or FLAG_MUTABLE be specified when creating a PendingIntent.
E/AndroidRuntime(31320): 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.

I believe that Issue #4 has addressed the similar issue for API 31 and above. Would it possible to lower the API level that PendingIntent.FLAG_IMMUTABLE flag is set with the outgoing pending intent, down to API 30?

Or possibly down to API 23 that the flag is first introduced.

kmemo commented 2 years ago

FYI:

flutter_overlay_window/android/src/main/java/flutter/overlay/window/flutter_overlay_window/OverlayService.java

176: if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.S) { 177: pendingFlags = PendingIntent.FLAG_IMMUTABLE; 178: } else { 179: pendingFlags = PendingIntent.FLAG_UPDATE_CURRENT; 180: }

For a Android API 30 emulator to run one of my codes with flutter_overlay_window plugin, I had to modify the line 176 of OverlayService.java as:

176: if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {

Reference https://stackoverflow.com/a/70627228

buihongvinh commented 2 years ago

It not work for me . I got this error when change in line 176 . Pls help to fix it. Thanks Screen Shot 2022-10-04 at 17 05 12

buihongvinh commented 2 years ago

I got this screen when i click Show overlay ![Uploading Screen Shot 2022-10-04 at 17.06.00.png…]()

X-SLAYER commented 1 year ago

https://github.com/X-SLAYER/flutter_overlay_window/issues/48#issuecomment-1474805011

kmemo commented 1 year ago

FYI:

flutter_overlay_window/android/src/main/java/flutter/overlay/window/flutter_overlay_window/OverlayService.java

176: if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.S) { 177: pendingFlags = PendingIntent.FLAG_IMMUTABLE; 178: } else { 179: pendingFlags = PendingIntent.FLAG_UPDATE_CURRENT; 180: }

For a Android API 30 emulator to run one of my codes with flutter_overlay_window plugin, I had to modify the line 176 of OverlayService.java as:

176: if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {

Reference https://stackoverflow.com/a/70627228

I am not able to see changes to the codes of the new version of the plugin (0.4.1) in regards to this issue. This issue has been closed but no explanation how this issue has been adressed by the team.

X-SLAYER commented 1 year ago

I will retry it because I already tested it on real API30 SDK I will try it on an emulator