Avatar ·

Error startForeground después de actualizar a Android 8.1: ¿cómo solucionarlo?

¡Hola a todos! Estoy desarrollando una aplicación en Kotlin que usa un background service para rastrear la ubicación. Después de actualizar el dispositivo a Android 8.1 (Oreo), mi service dejó de funcionar y falla con el error `Context.startForegroundService() did not then call Service.startForeground()`. Aquí está mi código del service: ```kotlin class LocationService : Service() { override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int { val notification = NotificationCompat.Builder(this, "channel_id") .setContentTitle("Servicio activo") .setContentText("Rastreo de ubicación") .setSmallIcon(R.drawable.ic_location) .build() startForeground(1, notification) return START_STICKY } override fun onBind(intent: Intent?): IBinder? = null } ``` Y lo inicio así: ```kotlin val intent = Intent(this, LocationService::class.java) if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {