Почему мое приложение дает сбой при отладке с остановленным приложением? - PullRequest
0 голосов
/ 07 мая 2020

Сборка выполняется успешно, но закрывается с уведомлением «Приложение остановлено» на моем устройстве мониторинга. У меня в журнале есть следующие ошибки:

2020-05-07 08:57:47.729 22899-22899/? E/libc: Access denied finding property "persist.vendor.sys.activitylog"
2020-05-07 08:57:54.781 22899-22899/net.groupkse.indupendo E/MediaPlayerNative: stop called in state 1, mPlayer(0x0)
2020-05-07 08:57:54.781 22899-22899/net.groupkse.indupendo E/MediaPlayerNative: error (-38, 0)
2020-05-07 08:57:54.930 22899-22925/net.groupkse.indupendo E/libc: Access denied finding property "persist.vendor.log.tel_dbg"
2020-05-07 08:57:55.355 22899-22972/net.groupkse.indupendo E/libARC: item map does not been created yet!
2020-05-07 08:57:55.395 22899-22899/net.groupkse.indupendo E/MediaPlayer: Error (-38,0)
2020-05-07 08:57:55.412 22899-22899/net.groupkse.indupendo E/AndroidRuntime: FATAL EXCEPTION: main
    Process: net.groupkse.indupendo, PID: 22899
    android.app.RemoteServiceException: Bad notification for startForeground: java.lang.RuntimeException: invalid channel for service notification: Notification(channel=null pri=0 contentView=null vibrate=null sound=null tick defaults=0x0 flags=0x42 color=0x00000000 actions=3 vis=PRIVATE)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1790)
        at android.os.Handler.dispatchMessage(Handler.java:106)
        at android.os.Looper.loop(Looper.java:193)
        at android.app.ActivityThread.main(ActivityThread.java:6819)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:497)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:912)

Где может быть проблема?

1 Ответ

4 голосов
/ 07 мая 2020

Вы сначала зарегистрировали свой канал уведомлений, используя createNotificationChannel? Пример кода ниже, взятый из Android документации разработчика :

private void createNotificationChannel() {
    // Create the NotificationChannel, but only on API 26+ because
    // the NotificationChannel class is new and not in the support library
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
        CharSequence name = getString(R.string.channel_name);
        String description = getString(R.string.channel_description);
        int importance = NotificationManager.IMPORTANCE_DEFAULT;
        NotificationChannel channel = new NotificationChannel(CHANNEL_ID, name, importance);
        channel.setDescription(description);
        // Register the channel with the system; you can't change the importance
        // or other notification behaviors after this
        NotificationManager notificationManager = getSystemService(NotificationManager.class);
        notificationManager.createNotificationChannel(channel);
    }
}
...