Good afternoon. I use custom notification sounds in my project, the initial compilation does not give errors and the sounds are played. In the future, when changes are made in other parts of the code and the subsequent side, notifications come without sound, an error occurs in LogCat:
Failed to open file 'android.resource://inwou.onetgroup.inwouapp/2131755009'. (No such file or directory)
the notification file, as expected, is located in the /raw folder
My Code:
private fun createNotificationChannelRegular() {
Log.e(
"Inwou",
"Regualr notification Channel ----------------------------------"
)
val serviceChannelRegular =
NotificationChannel(REGULAR_ID, "Status", NotificationManager.IMPORTANCE_HIGH)
val manager = getSystemService(NotificationManager::class.java)
val audioAttr: AudioAttributes? = AudioAttributes.Builder()
.setContentType(AudioAttributes.CONTENT_TYPE_SONIFICATION)
.setUsage(AudioAttributes.USAGE_NOTIFICATION_EVENT)
.setFlags(AudioAttributes.FLAG_AUDIBILITY_ENFORCED)
.build()
serviceChannelRegular.lockscreenVisibility = Notification.VISIBILITY_PUBLIC
serviceChannelRegular.enableLights(true)
serviceChannelRegular.enableVibration(true)
serviceChannelRegular.setSound(
Uri.parse("android.resource://" + this.packageName + "/" + R.raw.message3),
audioAttr
)
Log.w("Inwou", "Парсинг звукового файла ${this.packageName}/${R.raw.message3}")
manager.createNotificationChannel(serviceChannelRegular)
}
if you rename the file using refactoring and build the project again, the sound appears again.
I use : Android studio Dolphin 2021.3.1 Patch 1 Target SDK 33
Thank you in advance
I tried to rename the file, but it didn't give the desired result
upd. In the log file, I saw that logging from the code points to 1 file, and the error to another. The difference is 1 digit.