Avatar ·

Error startForeground después de actualizar a Android 8.1: la aplicación falla con ForegroundServiceDidNotStartInTimeException

¡Hola a todos! Soy un desarrollador Android principiante en Kotlin. Después de actualizar mi dispositivo a Android 8.1 (Oreo), mi aplicación comenzó a fallar con un error al iniciar el servicio en segundo plano. Anteriormente, en Android 7.0, todo funcionaba perfectamente. Aquí está mi código del servicio: ```kotlin class MyForegroundService : Service() { override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int { val notification = Notification.Builder(this, "my_channel") .setContentTitle("Servicio en ejecución") .setContentText("Cargando...") .setSmallIcon(R.drawable.ic_notification) .build() startForeground(1, notification) // ... tarea larga en segundo plano return START_STICKY } override fun onBind(intent: Intent?): IBinder? = null } ``` Y así es como inicio el servicio desde Activity: ```kotlin startService(Intent(this, MyForegroundService::class.java)) ``` Error en los logs: `android.app.ForegroundServiceDidN