[TIMOB-25529] Android: When custom sound is used the app crashes and the device stops receiving notifications
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | Critical |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2017-12-11T19:58:53.000+0000 |
Affected Version/s | n/a |
Fix Version/s | n/a |
Components | n/a |
Labels | CloudPush, android |
Reporter | Andreas Pingas |
Assignee | Eric Merriman |
Created | 2017-11-06T18:34:53.000+0000 |
Updated | 2017-12-11T19:58:53.000+0000 |
Description
*Hello everyone,
We have recently came across this bug. When custom sound used in Android the app crashes and the device stops receiving notifications.
Do you have any solution on that matter? Thank you in advance!*
[ERROR] : TiApplication: (main) [10869,132969] Sending event: exception on thread: main msg:java.lang.RuntimeException: Unable to start receiver com.appcelerator.aps.GCMReceiver: android.os.FileUriExposedException: link/RM.wav exposed beyond app through Notification.sound; Titanium 6.3.0,2017/10/31 18:13,undefined
[ERROR] : TiApplication: java.lang.RuntimeException: Unable to start receiver com.appcelerator.aps.GCMReceiver: android.os.FileUriExposedException: link/RM.wav exposed beyond app through Notification.sound
[ERROR] : TiApplication: at android.app.ActivityThread.handleReceiver(ActivityThread.java:3060)
[ERROR] : TiApplication: at android.app.ActivityThread.-wrap18(ActivityThread.java)
[ERROR] : TiApplication: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1584)
[ERROR] : TiApplication: at android.os.Handler.dispatchMessage(Handler.java:102)
[ERROR] : TiApplication: at android.os.Looper.loop(Looper.java:160)
[ERROR] : TiApplication: at android.app.ActivityThread.main(ActivityThread.java:6200)
[ERROR] : TiApplication: at java.lang.reflect.Method.invoke(Native Method)
[ERROR] : TiApplication: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:874)
[ERROR] : TiApplication: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:764)
[ERROR] : TiApplication: Caused by: android.os.FileUriExposedException: link/RM.wav exposed beyond app through Notification.sound
[ERROR] : TiApplication: at android.os.StrictMode.onFileUriExposed(StrictMode.java:1799)
[ERROR] : TiApplication: at android.net.Uri.checkFileUriExposed(Uri.java:2346)
[ERROR] : TiApplication: at android.app.NotificationManager.notifyAsUser(NotificationManager.java:300)
[ERROR] : TiApplication: at android.app.NotificationManager.notify(NotificationManager.java:284)
[ERROR] : TiApplication: at android.app.NotificationManager.notify(NotificationManager.java:268)
[ERROR] : TiApplication: at com.appcelerator.aps.APSCloudPush.showTrayNotification(APSCloudPush.java:523)
[ERROR] : TiApplication: at com.appcelerator.aps.APSCloudPush.receivePayload(APSCloudPush.java:253)
[ERROR] : TiApplication: at com.appcelerator.aps.GCMReceiver.onReceive(GCMReceiver.java:30)
[ERROR] : TiApplication: at android.app.ActivityThread.handleReceiver(ActivityThread.java:3053)
[ERROR] : TiApplication: ... 8 more
Hello [~andreas.pingas], Thanks for sharing with us.Please create a full reproducible test code and provide here for us to test the issue. Also, provide detail affected environment. Thanks.
[~andreas.pingas], this is a known issue that happens on Android 7.0 and newer OS versions. The issue is that if your app targets Android 7.0 (aka: API Level 24) or higher, then we need to grant read permissions to external apps (the OS' NotificationManager in this case) to read your app's sandboxed files (the custom sound file). But unfortunately, this is kind of a design issue on Google's end (see link below) because there isn't a way to solve this without making an "assumption" regarding which background process name needs access to your custom sound file, which isn't a 100% full proof solution. Especially considering the Android forks that exist in the wild. https://issuetracker.google.com/issues/37118905 For the moment, you can work-around this issue by targeting API Level 23 or lower in your "tiapp.xml" file.
Hello [~andreas.pingas], Did you manage to follow [~jquick]'s instructions? Best
Hello [~andreas.pingas], please get back to us on on the workaround that Joshua provided. Thanks.
I have used targetSdkVersion 25. There is no issue on targetSdkVersion 23. We have removed the custom sounds. If i use targetSdkVersion 23 I get the following: [ERROR] : The target SDK API 23 is not supported by Titanium SDK 6.3.0 Update the android:targetSdkVersion in the tiapp.xml or custom AndroidManifest to at least 25: [ERROR] : The target SDK API version must be 25 or newer
[~andreas.pingas], Oh shoot, you're right. The min target API Level is 25 on Titanium 6.2.2 and above. Titanium 6.2.1 can be set to API Level 23.
[~jquick] Can we add the Android bug-report link and a short note to the related docs as well? It might help people getting rid of that issue more easily.
[~andreas.pingas], [~hknoechel], We're looking into resolving this custom notification sound issue by the time Titanium 7.0.0. gets released. Also, in Titanium 7.0.0, we're lowering the min target API Level from 25 to 23 as well. Stay tuned!
This was resolved in 7.0.0. Sorry, there was a duplicate ticket on this issue [NATIVESDK-353] and it was closed instead.