0

Такая проблема, на Huawei INE-LX1, крешится приложение при создании канала уведомлений, при этом раньше работало нормально. В чём может быть проблема?

private fun registerAlertNotificationChannel() {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
        // Create the NotificationChannel
        val channel = NotificationChannel(
            "fcm_eshmun_alert_channel",
            getString(R.string.fcm_alert_channel_name),
            NotificationManager.IMPORTANCE_HIGH
        )
        channel.description = getString(R.string.fcm_alert_channel_description)
        channel.enableLights(true)
        channel.enableVibration(true)
        channel.lockscreenVisibility = Notification.VISIBILITY_PUBLIC
        channel.lightColor = Color.GREEN
        channel.setSound(
            Utils.getResourceUri(this, R.raw.sos),
            AudioAttributes.Builder().setUsage(AudioAttributes.USAGE_NOTIFICATION_RINGTONE).build()
        )
        // Register the channel with the system; you can't change the importance
        // or other notification behaviors after this
        val notificationManager = getSystemService(NOTIFICATION_SERVICE) as NotificationManager
        notificationManager.createNotificationChannel(channel)
    }
}

Лог невероятно содержателен:

java.lang.RuntimeException: Unable to create application com.eshmun.mobile.App: java.lang.IllegalArgumentException
    at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6737)
    at android.app.ActivityThread.access$2000(ActivityThread.java:273)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2020)
    at android.os.Handler.dispatchMessage(Handler.java:112)
    at android.os.Looper.loop(Looper.java:216)
    at android.app.ActivityThread.main(ActivityThread.java:7625)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:524)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:987)
 Caused by: java.lang.IllegalArgumentException
    at android.os.Parcel.createException(Parcel.java:1957)
    at android.os.Parcel.readException(Parcel.java:1921)
    at android.os.Parcel.readException(Parcel.java:1871)
    at android.app.INotificationManager$Stub$Proxy.createNotificationChannels(INotificationManager.java:1773)
    at android.app.NotificationManager.createNotificationChannels(NotificationManager.java:541)
    at android.app.NotificationManager.createNotificationChannel(NotificationManager.java:529)
    at com.eshmun.mobile.App.registerAlertNotificationChannel(App.kt:129)
    at com.eshmun.mobile.App.onCreate(App.kt:55)
    at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1162)
    at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6717)
    at android.app.ActivityThread.access$2000(ActivityThread.java:273) 
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2020) 
    at android.os.Handler.dispatchMessage(Handler.java:112) 
    at android.os.Looper.loop(Looper.java:216) 
    at android.app.ActivityThread.main(ActivityThread.java:7625) 
    at java.lang.reflect.Method.invoke(Native Method) 
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:524) 
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:987) 
 Caused by: android.os.RemoteException: Remote stack trace:
    at com.android.internal.util.Preconditions.checkArgument(Preconditions.java:33)
    at com.android.server.notification.RankingHelper.createNotificationChannel(RankingHelper.java:652)
    at com.android.server.notification.NotificationManagerService$11.createNotificationChannelsImpl(NotificationManagerService.java:2638)
    at com.android.server.notification.NotificationManagerService$11.createNotificationChannels(NotificationManagerService.java:2653)
    at android.app.INotificationManager$Stub.onTransact(INotificationManager.java:256)

P.S. При комментировании строчки: notificationManager.createNotificationChannel(channel)

1

1 ответ 1

0

Скорее всего у Тебя что-то равно null, проверь getString(R.string.fcm_alert_channel_name) какое значение возвращает.

0

Ваш ответ

Нажимая на кнопку «Отправить ответ», вы соглашаетесь с нашими условиями использования и подтверждаете, что прочитали и поняли наши политику конфиденциальности и нормы поведения.

Всё ещё ищете ответ? Посмотрите другие вопросы с метками или задайте свой вопрос.