Skip to content

App crashes when adding a new note after deleting all existing notes #40

@cka-dev

Description

@cka-dev

When I remove all current notes in the app and then try to add a new one, it crashes with this error:

E Error retrieving note: The query result was empty, but expected a single row to return a NON-NULL object of type 'com.example.cahier.data.Note'.
2026-01-14 20:35:01.385 22692-22692 HomeScreenViewModel com.example.cahier E Error retrieving note: The query result was empty, but expected a single row to return a NON-NULL object of type 'com.example.cahier.data.Note'.
2026-01-14 20:35:01.389 22692-22692 HomeScreenViewModel com.example.cahier E Error retrieving note: The query result was empty, but expected a single row to return a NON-NULL object of type 'com.example.cahier.data.Note'.
2026-01-14 20:35:02.402 22692-22692 HomeScreenViewModel com.example.cahier E Error retrieving note: The query result was empty, but expected a single row to return a NON-NULL object of type 'com.example.cahier.data.Note'.
2026-01-14 20:35:02.439 22692-22692 HomeScreenViewModel com.example.cahier E Error retrieving note: The query result was empty, but expected a single row to return a NON-NULL object of type 'com.example.cahier.data.Note'.
2026-01-14 20:35:03.137 22692-22692 HomeScreenViewModel com.example.cahier E Error retrieving note: The query result was empty, but expected a single row to return a NON-NULL object of type 'com.example.cahier.data.Note'.
2026-01-14 20:35:05.307 22692-22692 HomeScreenViewModel com.example.cahier E Error retrieving note: The query result was empty, but expected a single row to return a NON-NULL object of type 'com.example.cahier.data.Note'.
2026-01-14 20:35:07.024 22692-22692 WindowOnBackDispatcher com.example.cahier D setTopOnBackInvokedCallback (unwrapped): androidx.navigationevent.OnBackInvokedInput$createOnBackAnimationCallback$1@4855c92
2026-01-14 20:35:07.226 22692-22692 nativeloader com.example.cahier D Load /data/app/_3hXb4bKPJ6HhruVv43C6g==/com.example.cahier-YjnNNo-A0uWFxZpranjBUQ==/base.apk!/lib/arm64-v8a/libgraphics-core.so using class loader ns clns-9 (caller=/data/app/_3hXb4bKPJ6HhruVv43C6g==/com.example.cahier-YjnNNo-A0uWFxZpranjBUQ==/base.apk!classes10.dex): ok
2026-01-14 20:35:07.226 22692-22692 ASurfaceControlTest com.example.cahier E GraphicsCore JNI_OnLoad start
2026-01-14 20:35:09.024 22692-22692 tflite com.example.cahier I Initialized TensorFlow Lite runtime.
2026-01-14 20:35:09.134 22692-22692 WindowOnBackDispatcher com.example.cahier D setTopOnBackInvokedCallback (unwrapped): android.app.Activity$$ExternalSyntheticLambda0@dd6d868
2026-01-14 20:35:09.247 22692-22692 System.out com.example.cahier I FocusRelatedWarning:
2026-01-14 20:35:09.247 22692-22692 System.out com.example.cahier I FocusRequester is not initialized. Here are some possible fixes:
2026-01-14 20:35:09.247 22692-22692 System.out com.example.cahier I
2026-01-14 20:35:09.247 22692-22692 System.out com.example.cahier I 1. Remember the FocusRequester: val focusRequester = remember { FocusRequester() }
2026-01-14 20:35:09.247 22692-22692 System.out com.example.cahier I 2. Did you forget to add a Modifier.focusRequester() ?
2026-01-14 20:35:09.247 22692-22692 System.out com.example.cahier I 3. Are you attempting to request focus during composition? Focus requests should be made in
2026-01-14 20:35:09.247 22692-22692 System.out com.example.cahier I response to some event. Eg Modifier.clickable { focusRequester.requestFocus() }
2026-01-14 20:35:09.297 22692-22692 WindowLayo...ponentImpl com.example.cahier D Register WindowLayoutInfoListener on Context=com.example.cahier.MainActivity@df0d210, of which baseContext=android.app.ContextImpl@b8f9d94
2026-01-14 20:35:10.792 22692-22692 HomeScreenViewModel com.example.cahier E Error retrieving note: The query result was empty, but expected a single row to return a NON-NULL object of type 'com.example.cahier.data.Note'.
2026-01-14 20:35:13.074 22692-22692 WindowOnBackDispatcher com.example.cahier D setTopOnBackInvokedCallback (unwrapped): androidx.navigationevent.OnBackInvokedInput$createOnBackAnimationCallback$1@4855c92
2026-01-14 20:35:13.233 22692-22692 AndroidRuntime com.example.cahier E FATAL EXCEPTION: main (Fix with AI)
Process: com.example.cahier, PID: 22692
java.lang.IllegalStateException: changeId PointerId(value=51) not mapped to a pointerId.
at androidx.ink.authoring.compose.InProgressShapesKt$InProgressShapesImpl$4$1$1.invokeSuspend(InProgressShapes.kt:286)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:34)
at kotlinx.coroutines.DispatchedTaskKt.resume(DispatchedTask.kt:163)
at kotlinx.coroutines.DispatchedTaskKt.dispatch(DispatchedTask.kt:152)
at kotlinx.coroutines.CancellableContinuationImpl.dispatchResume(CancellableContinuationImpl.kt:470)
at kotlinx.coroutines.CancellableContinuationImpl.resumeImpl$kotlinx_coroutines_core(CancellableContinuationImpl.kt:504)
at kotlinx.coroutines.CancellableContinuationImpl.resumeImpl$kotlinx_coroutines_core$default(CancellableContinuationImpl.kt:493)
at kotlinx.coroutines.CancellableContinuationImpl.resumeWith(CancellableContinuationImpl.kt:359)
at androidx.compose.ui.input.pointer.SuspendingPointerInputModifierNodeImpl$PointerEventHandlerCoroutine.offerPointerEvent(SuspendingPointerInputFilter.kt:829)
at androidx.compose.ui.input.pointer.SuspendingPointerInputModifierNodeImpl.dispatchPointerEvent(SuspendingPointerInputFilter.kt:699)
at androidx.compose.ui.input.pointer.SuspendingPointerInputModifierNodeImpl.onPointerEvent-H0pRuoY(SuspendingPointerInputFilter.kt:725)
at androidx.compose.ui.input.pointer.Node.dispatchMainEventPass(HitPathTracker.kt:446)
at androidx.compose.ui.input.pointer.Node.dispatchMainEventPass(HitPathTracker.kt:432)
at androidx.compose.ui.input.pointer.NodeParent.dispatchMainEventPass(HitPathTracker.kt:285)
at androidx.compose.ui.input.pointer.HitPathTracker.dispatchChanges(HitPathTracker.kt:181)
at androidx.compose.ui.input.pointer.PointerInputEventProcessor.process-BIzXfog(PointerInputEventProcessor.kt:118)
at androidx.compose.ui.platform.AndroidComposeView.sendSimulatedEvent(AndroidComposeView.android.kt:2767)
at androidx.compose.ui.platform.AndroidComposeView.access$sendSimulatedEvent(AndroidComposeView.android.kt:264)
at androidx.compose.ui.platform.AndroidComposeView$resendMotionEventRunnable$1.run(AndroidComposeView.android.kt:895)
at android.os.Handler.handleCallback(Handler.java:1070)
at android.os.Handler.dispatchMessage(Handler.java:125)
at android.os.Looper.dispatchMessage(Looper.java:333)
at android.os.Looper.loopOnce(Looper.java:263)
at android.os.Looper.loop(Looper.java:367)
at android.app.ActivityThread.main(ActivityThread.java:9287)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:566)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:929)
Suppressed: kotlinx.coroutines.internal.DiagnosticCoroutineContextException: [androidx.compose.ui.platform.MotionDurationScaleImpl@5bda217, androidx.compose.runtime.BroadcastFrameClock@deb3604, StandaloneCoroutine{Cancelling}@2b367ed, AndroidUiDispatcher@e5ba622]
2026-01-14 20:35:13.247 22692-22692 Process com.example.cahier I Sending signal. PID: 22692 SIG: 9

This is likely caused by NoteDao and NoteRepository return Flow instead of a nullable Note.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions