Cordova-plugin-local-notifications: Local-notification plugin crash on notification event on android 7

Created on 2 Apr 2017  路  21Comments  路  Source: katzer/cordova-plugin-local-notifications

Local-notification plugin crash on notification event on android 7
It worked OK on android 6, just after upgrading to android 7 it started to crash

Only when tapping the notification the application crash (Both if app in foreground or background)

Enviroment:
Plugin version: 0.8.4
Platform: Android
OS version: 7.0
Device manufacturer / model: Samsung 6 edge+
Cordova version (cordova -v): 6.4.0
Cordova platform version (cordova platform ls): android 6.0.0 platform

bug android

Most helpful comment

Below are the two error messages created upon application crash (due to unhandled exception)

04-28 22:10:12.580 10105 10105 E AndroidRuntime: java.lang.RuntimeException: Unable to start receiver de.appplant.cordova.plugin.localnotification.TriggerReceiver: android.os.FileUriExposedException: file:///storage/emulated/0/Android/data/this.app/cache/localnotification/sound.m4a exposed beyond app through Notification.sound
04-28 22:10:12.580 10105 10105 E AndroidRuntime: Caused by: android.os.FileUriExposedException: file:///storage/emulated/0/Android/data/this.app/cache/localnotification/sound.m4a exposed beyond app through Notification.sound

Android SDK >= 24 have removed the file:// option as written here: https://developer.android.com/reference/android/os/FileUriExposedException.html

This plugin must most likely adopt the content:// protocol for Android. The following site explain how to do it for Android in general: https://inthecheesefactory.com/blog/how-to-share-access-to-file-with-fileprovider-on-android-nougat/en

Until then a simple workaround is to set android:targetSdkVersion="23" in your AndroidManifest.xml

All 21 comments

Fill out #1188 as not enough information here

same here

What crashed?

What code?

The template asks for more information than what you have shown.

I know that the code doesn't crash when we use iit in Genymotiio.

The app crashed on Android 7 only you using a sound file mp3/wav. Android 6 it doesn't ocurrs.

Follow below the schedule that works on Android 6 and crash on Android 7.

$cordovaLocalNotification.schedule({
id: "1234",
at: new Date(new Date().getTime() + (2 * 1000)),
text: "Message",
title: "Title",
sound: "file://sounds/alarm.wav"
})

Thanks.

So if you remove sound: it works OK?

Yes, it works perfectly.

Hi guys,

we have the exact same issue, when you will resolve it ?

Best

Same here

Below are the two error messages created upon application crash (due to unhandled exception)

04-28 22:10:12.580 10105 10105 E AndroidRuntime: java.lang.RuntimeException: Unable to start receiver de.appplant.cordova.plugin.localnotification.TriggerReceiver: android.os.FileUriExposedException: file:///storage/emulated/0/Android/data/this.app/cache/localnotification/sound.m4a exposed beyond app through Notification.sound
04-28 22:10:12.580 10105 10105 E AndroidRuntime: Caused by: android.os.FileUriExposedException: file:///storage/emulated/0/Android/data/this.app/cache/localnotification/sound.m4a exposed beyond app through Notification.sound

Android SDK >= 24 have removed the file:// option as written here: https://developer.android.com/reference/android/os/FileUriExposedException.html

This plugin must most likely adopt the content:// protocol for Android. The following site explain how to do it for Android in general: https://inthecheesefactory.com/blog/how-to-share-access-to-file-with-fileprovider-on-android-nougat/en

Until then a simple workaround is to set android:targetSdkVersion="23" in your AndroidManifest.xml

+1

None of the above offered solution solved the problem.
The crash occures only when tapping the notification !!!!
If someone could check the reason for the crash in java code just after tapping the notification

yes, I got same crash when tap the notification.
But my Android version is 6.0.1 and model is Galaxy Tab S.
It works fine on my other device.(Galaxy S3)
Please help about that.
Thanks

+1

+1
Did anyone find any solution for it?

Thanks #vegham,
It works perfectly on android 7 after set android:targetSdkVersion="23"

Yeah.. it works perfectly after set android:targetSdkVersion="23".
Thanks.

setting android:targetSdkVersion="23" DIDN'T solved the crash that happens after clicking the notification.

android:targetSdkVersion="23" worked for me, thanks !

Same error here when click on a local notification (Android 7.1.2):

java.lang.RuntimeException: Unable to resume activity {com.jorgecacho.familiaalbertiana/de.appplant.cordova.plugin.localnotification.Clic kActivity}: java.lang.IllegalStateException: Activity {com.jorgecacho.familiaalbertiana/de.appplant.cordova.plugin.localnotification.ClickActivity} did not call finish() prior to onResum e() completing

I'vre tried to set minSdkVersion = 23, but it doesn0't fix the error, and I need to app to run on older devices ...

Is there any fix fot this?

That has been fixed 馃

Latest available version of this plugin (0.8.5) still exhibits the reported behaviour on this issue. I've seen there are lots of commits since that version, as the latest published version is from more than one year ago. Have you fixed it in one of those commits? In that case, can you please make a new release?

Since June 1, 2018 Google rejects apps compiled against older SDKs (minimum now is 26, so the workaround to use SDK 23 cannot be used for a production app).

Thanks!

Was this page helpful?
0 / 5 - 0 ratings