Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

App crashes on android 9.0

See original GitHub issue

Issue description

My app crashes on android 9.0(My phone is Xiaomi 8), it works well on earlier platform(Android 6.0, 7.0, 8.0).

It crashes when the screen turns off or I switch to another app.

Error log from Android Studio

Similar to

2019-02-21 21:08:28.938 6320-6320/cc.cs_tao.whu_library_seat_mobile E/AndroidRuntime: FATAL EXCEPTION: main
    Process: cc.cs_tao.whu_library_seat_mobile, PID: 6320 Bad notification for startForeground: java.lang.RuntimeException: invalid channel for service notification: Notification(channel=null pri=-2 contentView=null vibrate=null sound=null defaults=0x0 flags=0x42 color=0x00000000 vis=PRIVATE)
        at android.os.Handler.dispatchMessage(
        at android.os.Looper.loop(
        at java.lang.reflect.Method.invoke(Native Method)

My project info

Can anyone help me? Many thanks.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:5
  • Comments:22

github_iconTop GitHub Comments

edentocommented, Aug 22, 2019


I am having a problem on Android 9 as well when I pause the app.

As @CS-Tao mentioned this works for me also: cordova.plugins.backgroundMode.setDefaults({ silent: true });

What is the ramification for my app to setting silent true? Is it still going to work in the back ground?

From the app plugin:

In silent mode the plugin will not display a notification - which is not the default. Be aware that Android recommends adding a notification otherwise the OS may pause the app.

I was looking for another solution and found that:

You can also add the permission to Ionic 3 / Cordova apps by adding this in your config.xml under android platform:

    <platform name="android">
        <config-file parent="./" target="app/src/main/AndroidManifest.xml" xmlns:android="">
            <uses-permission android:name="android.permission.FOREGROUND_SERVICE" />

It fixed my crash issue. Now just need to test if android 9 leaves the app running in the background or it kills it after 5 minutes.

rubenstolkcommented, Sep 4, 2019

So I just found out that when the targetSdkVersion is set to 27, the plugin works perfectly well but when changing it to 28 the issue is back, and can only be solved by actively adding the FOREGROUND_SERVICE permission.

I think this issue should be reopened and the permission should be included in the plugin itself.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Mobile App crashes when using phone with Android 9.0
When using a phone running android 9.0 (such as Pixel 2 or Pixel XL), the RE Mobile App will not load and immediately...
Read more >
Fix an installed Android app that isn't working - Google Support
Try the following steps if an app installed on your phone has any of these problems: Crashing. Won't open. Won't respond. Isn't working...
Read more >
Android 9.0.9 - Google app crash - OnePlus Community
There is a bug associated with Parallel apps, that cause Google app to crash at opening, still no solution to it!
Read more >
My app crashes after updating in Android 9(Pie) - Stack Overflow
Yesterday my phone got updated to Android 9 and by that time my app started crashing. I reinstalled it from the Android Studio,...
Read more >
Android App Crashes in some Samsung Devices that running ...
We have not been able to reproduce this crash so far. The crash occurs only on Samsung devices with Android 9.0.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Post

No results found

github_iconTop Related Hashnode Post

No results found