flutter_overlay_window icon indicating copy to clipboard operation
flutter_overlay_window copied to clipboard

App crashes with "Unable to start service flutter.overlay.window.flutter_overlay_window.OverlayService"

Open neo-xy opened this issue 5 months ago • 9 comments

on eof my app functionalities displyas periodically message on screen when app it self is in the background to which I use the library. For a lot of users (20%) app crashes and sadly myself I could not repreduce it.

Fatal Exception: java.lang.RuntimeException: Unable to start service flutter.overlay.window.flutter_overlay_window.OverlayService@a6fb6c1 with null: java.lang.NullPointerException: Attempt to invoke virtual method 'int android.content.Intent.getIntExtra(java.lang.String, int)' on a null object reference at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:5770) at android.app.ActivityThread.-$$Nest$mhandleServiceArgs() at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2728) at android.os.Handler.dispatchMessage(Handler.java:107) at android.os.Looper.loopOnce(Looper.java:257) at android.os.Looper.loop(Looper.java:342) at android.app.ActivityThread.main(ActivityThread.java:9634) at java.lang.reflect.Method.invoke(Method.java) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:619) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:929)

`

<application
    android:label="Mind lies"
    android:name="${applicationName}"
    android:enableOnBackInvokedCallback="true"
    android:icon="@mipmap/ic_launcher">

    <service android:name="flutter.overlay.window.flutter_overlay_window.OverlayService"
        android:exported="false"
        android:foregroundServiceType="specialUse">
        <property android:name="android.app.PROPERTY_SPECIAL_USE_FGS_SUBTYPE"
            android:value="This functionality is needed for affirmations to be displayed even when the app is minimized."/>
    </service>

    <activity
        android:name=".MainActivity"
        android:exported="true"
        android:launchMode="singleTop"`

Preciate any help..

neo-xy avatar Jun 06 '25 07:06 neo-xy

more info: it crashes after a hour or two, (but only on some devices) Maybe race condition? Possible solution on top of the "onStartCommand"...:

if (intent == null) { Log.e("OverlayService", "onStartCommand: Intent is null!"); return START_STICKY; // Or handle appropriately }

??

neo-xy avatar Jun 08 '25 07:06 neo-xy

any fix for this?

NOTtheKRish avatar Jul 29 '25 02:07 NOTtheKRish

@NOTtheKRish
I forked it -> https://github.com/neo-xy/flutter_overlay_window

and added if (intent == null) { Log.e("OverlayService", "onStartCommand: Intent is null!"); return START_STICKY; }

and that fixed the issue although not 100% sure if that is the right way to go as I did not get any confirmation from @X-SLAYER

neo-xy avatar Jul 29 '25 07:07 neo-xy

@neo-xy Thanks for the response... I'll check it with an Internal Testing in Play Store and let you know if the issue is resolved...

NOTtheKRish avatar Jul 29 '25 12:07 NOTtheKRish

@neo-xy Hi mate.... your fork is working fine, but sometimes, while we try to open the overlay, it refuses to start in some android devices (specifically Android 13+)... Any idea why this behaviour?

NOTtheKRish avatar Aug 28 '25 04:08 NOTtheKRish

@NOTtheKRish specificly my fork that does not work on android 13 or the original library has the same issue?

neo-xy avatar Aug 28 '25 09:08 neo-xy

@neo-xy I used your fork in my app, tested using realme Narzo 70x 5G (Android 15) device, and found this issue

NOTtheKRish avatar Aug 28 '25 09:08 NOTtheKRish

ok, i'm guessing that it will be the saem if U test the main version - sadly nothing I can help with; @X-SLAYER is a go to guy for that

neo-xy avatar Aug 28 '25 10:08 neo-xy

I will try to fix it in the next push

X-SLAYER avatar Aug 28 '25 10:08 X-SLAYER