Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-25529] Android: When custom sound is used the app crashes and the device stops receiving notifications

GitHub Issuen/a
TypeBug
PriorityCritical
StatusClosed
ResolutionFixed
Resolution Date2017-12-11T19:58:53.000+0000
Affected Version/sn/a
Fix Version/sn/a
Componentsn/a
LabelsCloudPush, android
ReporterAndreas Pingas
AssigneeEric Merriman
Created2017-11-06T18:34:53.000+0000
Updated2017-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

Comments

  1. Mostafizur Rahman 2017-11-07

    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.
  2. Joshua Quick 2017-11-07

    [~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.
       <android xmlns:android="http://schemas.android.com/apk/res/android">
       	<manifest>
       		<uses-sdk android:minSdkVersion="16" android:targetSdkVersion="23"/>
       	</manifest>
       </android>
       
  3. Mostafizur Rahman 2017-11-09

    Hello [~andreas.pingas], Did you manage to follow [~jquick]'s instructions? Best
  4. Sharif AbuDarda 2017-11-11

    Hello [~andreas.pingas], please get back to us on on the workaround that Joshua provided. Thanks.
  5. Andreas Pingas 2017-11-13

    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 http://ti.appcelerator.org"> [ERROR] Application Installer abnormal process termination. Process exit value was 1 targetSdkVersion 23 is not supported from SDK 6.3.0. It is stated that it supports 23-26 but only 25-26 it is supported.
  6. Joshua Quick 2017-11-13

    [~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.
  7. Hans Knöchel 2017-11-14

    [~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.
  8. Joshua Quick 2017-11-16

    [~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!
  9. Joshua Quick 2017-12-11

    This was resolved in 7.0.0. Sorry, there was a duplicate ticket on this issue [NATIVESDK-353] and it was closed instead.

JSON Source