Я действительно запутался, как происходят эти сбои, поскольку я тестировал на реальном устройстве Oreo, и приложение работает без сбоев, но в отчете консоли Google Play у меня 34,92 тыс. Сбоев для устройств Android 8.0, 8.1.
отчет о сбое из Play consolole java.lang.RuntimeException:
java.lang.RuntimeException:
at android.app.ActivityThread.handleReceiver
(ActivityThread.java:3194)
at android.app.ActivityThread.-wrap17 (Unknown Source)
at android.app.ActivityThread$H.handleMessage
(ActivityThread.java:1672)
at android.os.Handler.dispatchMessage (Handler.java:106)
at android.os.Looper.loop (Looper.java:164)
at android.app.ActivityThread.main (ActivityThread.java:6501)
at java.lang.reflect.Method.invoke (Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run
(RuntimeInit.java:460)
at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:807)
отчет о сбое из Play consolole java.lang.IllegalStateException:
Caused by: java.lang.IllegalStateException:
at android.app.ContextImpl.startServiceCommon (ContextImpl.java:1521)
at android.app.ContextImpl.startService (ContextImpl.java:1477)
at android.content.ContextWrapper.startService
(ContextWrapper.java:650)
at android.content.ContextWrapper.startService
(ContextWrapper.java:650)
at com.myapp.package.service.BootReceiver.receive
(BootReceiver.kt:39)
at com.myapp.package.service.CoreReceiver.onReceive
(CoreReceiver.java:62)
at android.app.ActivityThread.handleReceiver (ActivityThread.java:3187)
мой код для BootReceiver
} else if (FIRE_INTENT == action) {
val alarmedIntent = intent.getParcelableExtra<Intent>
(ALARMED_INTENT)
val alarmedAction = alarmedIntent.action
Timber.i("BootReceiver Got alarm to fire alarmedIntent %s",
alarmedAction)
alarmedIntent.putExtra(CoreReceiver.WAKE_LOCK_ID, tmpWakeLockId)
tmpWakeLockId = null
context.startService(alarmedIntent)
} else if (SCHEDULE_INTENT == action) {
val atTime = intent.getLongExtra(AT_TIME, -1)
val alarmedIntent = intent.getParcelableExtra<Intent>
(ALARMED_INTENT)
Timber.i("BootReceiver Scheduling intent %s for %tc",
alarmedIntent, atTime)
val pi = buildPendingIntent(context, intent)
val alarmMgr = K9AlarmManager.getAlarmManager(context)
alarmMgr.set(AlarmManager.RTC_WAKEUP, atTime, pi)
}
для CoreReceiver
@Override
public void onReceive(Context context, Intent intent) {
Integer tmpWakeLockId = CoreReceiver.getWakeLock(context);
try {
Timber.i("CoreReceiver.onReceive %s", intent);
if (CoreReceiver.WAKE_LOCK_RELEASE.equals(intent.getAction())) {
Integer wakeLockId = intent.getIntExtra(WAKE_LOCK_ID, -1);
if (wakeLockId != -1) {
Timber.v("CoreReceiver Release wakeLock %d",
wakeLockId);
CoreReceiver.releaseWakeLock(wakeLockId);
}
} else {
tmpWakeLockId = receive(context, intent, tmpWakeLockId);
}
} finally {
CoreReceiver.releaseWakeLock(tmpWakeLockId);
}
}