Notification channel exception in indoor sdk since android 8(Oreo)

Hi there.
i´m testing the app in a phone wih andoid 8 onwards and appears to me the next exception

android.app.RemoteServiceException: Bad notification for startForeground: java.lang.RuntimeException: invalid channel for service notification: Notification(channel=null pri=1 contentView=null vibrate=null sound=null defaults=0x0 flags=0x40 color=0x00000000 backgroundColor=0x00000000 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:164)
        at android.app.ActivityThread.main(ActivityThread.java:6651)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:810)

for try to fix the problem i develop the next code

class ForegroudService: Service() {
    override fun onBind(intent: Intent?): IBinder? {
        TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
    }

    override fun onCreate() {
        super.onCreate()
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
            startForeground()
        } else {
            startForeground(1, Notification())
        }
    }
    @RequiresApi(Build.VERSION_CODES.O)
    fun startForeground() {

        val NOTIFICATION_CHANNEL_ID = "com.estimote.indoorapp"
        val channelName = "My Background Service"
        val chan = NotificationChannel(NOTIFICATION_CHANNEL_ID, channelName, IMPORTANCE_HIGH)
        chan.lightColor = Color.BLUE
        chan.lockscreenVisibility = Notification.VISIBILITY_PRIVATE
        val manager = getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
        manager.createNotificationChannel(chan)

        val notificationBuilder = Builder(this, NOTIFICATION_CHANNEL_ID)
        val notification = notificationBuilder.setOngoing(true)
                .setSmallIcon(R.drawable.logo_app)
                .setContentTitle("Find IT \u00AE")
                .setContentText("Geoposicionamiento de interiores")
                .setVisibility(VISIBILITY_PUBLIC)
                .setChannelId(NOTIFICATION_CHANNEL_ID)
                .setOnlyAlertOnce(true)
                .setPriority(PRIORITY_HIGH)
                .setCategory(CATEGORY_SERVICE)
                .build()
        startForeground(2, notification)
    }
}

but i don’t know if is missing somethig because it the code execute but after activate the gps location permision the app crashes and this throws me the same exception

help me please for fix this problem for mi app can operate in all andoid API aviable versions
Best Regards.

Do you use the Estimote Proximity SDK for Android? Do you use the withScanningInForegroundService? If yes, can you share your code that builds the Observer and calls withScanningInForegroundService?

Most likely, the missing/wrong channel is in the notification you pass to withScanningInForegroundService.

hi heypiotr
i just got this code of the indoor sdk related to withScanningInForegroundService:

val cloudCredentials = EstimoteCloudCredentials(“findit-esq”, “eb80ed8051e67a9271b760494f7eeaa5”)
indoorLocationManager = IndoorLocationManagerBuilder(this, location, cloudCredentials)
.withScannerInForegroundService(notification)
.build()
this is original code that this in inddor sdk but how can adapt this code for me to receive the notificaton channel as parameter?
help me please.
best regard.

Just take the part of your existing code that you shared above, where you create a notification with a channel:

        val NOTIFICATION_CHANNEL_ID = "com.estimote.indoorapp"
        val channelName = "My Background Service"
        val chan = NotificationChannel(NOTIFICATION_CHANNEL_ID, channelName, IMPORTANCE_HIGH)
        chan.lightColor = Color.BLUE
        chan.lockscreenVisibility = Notification.VISIBILITY_PRIVATE
        val manager = getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
        manager.createNotificationChannel(chan)

        val notificationBuilder = Builder(this, NOTIFICATION_CHANNEL_ID)
        val notification = notificationBuilder.setOngoing(true)
                .setSmallIcon(R.drawable.logo_app)
                .setContentTitle("Find IT \u00AE")
                .setContentText("Geoposicionamiento de interiores")
                .setVisibility(VISIBILITY_PUBLIC)
                .setChannelId(NOTIFICATION_CHANNEL_ID)
                .setOnlyAlertOnce(true)
                .setPriority(PRIORITY_HIGH)
                .setCategory(CATEGORY_SERVICE)
                .build()

… and pass that notification to .withScannerInForegroundService(notification)