-
Notifications
You must be signed in to change notification settings - Fork 854
Description
Describe your issue. If applicable, add screenshots to help explain your problem.
The application is experiencing a NullPointerException within com.google_mlkit_document_scanner.DocumentScanner.handleScanningResult when attempting to invoke a method on a null object reference, specifically Ug.j$d.a(java.lang.Object) .
This crash occurs during the activity resume lifecycle stage, following an onActivityResult call, and is wrapped in a RuntimeException during result delivery.
The issue is primarily observed on Huawei devices, suggesting a potential device-specific incompatibility or behavior difference. NullPointerException s are very common in Android development and often indicate that an object expected to be non-null has not been initialized or has been prematurely deallocated or cleared.
Potential Causes:
- Uninitialized Object Reference: The most direct cause is that the Ug.j$d object, or an object leading to it, is null when a(java.lang.Object) is called. This could be due to:
- Failure to initialize Ug.j$d before handleScanningResult is called.
- Asynchronous operations where Ug.j$d is set to null or not yet available when handleScanningResult is invoked.
- Lifecycle issues where the object is destroyed or reset to null between the onActivityResult and handleScanningResult execution.
Device-Specific Behavior (Huawei): The observation that this issue is specific to Huawei devices is critical. Huawei devices often have highly optimized power management and background process killers, or custom ROM modifications that can affect application lifecycle, background execution, or how system services (like those handling camera or document scanning results) interact with apps.
This could lead to:
- Aggressive termination of processes or activities that are not in the foreground, causing objects to be garbage collected or reset to null unexpectedly.
- Differences in how ResultInfo data or Intent extras are handled or preserved across activity restarts/resumes, potentially leading to missing data that DocumentScanner expects.
- Specific implementations of underlying ML Kit dependencies or system APIs that differ on Huawei devices.
Timing/Race Condition: The crash occurring during performResumeActivity and deliverResults suggests a potential race condition where handleScanningResult is invoked before necessary components are fully ready or after they have been unexpectedly torn down. - Improper Lifecycle Handling in DocumentScanner : The DocumentScanner class might not be robustly handling all possible activity lifecycle events or edge cases, particularly when an activity is recreated or resumed under specific conditions.
Fatal Exception: java.lang.RuntimeException: Unable to resume activity {com.myappname/com.myappname.MainActivity}: java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=3548984, result=-1, data=Intent { (has extras) }} to activity {com.myappname/com.myappname.MainActivity}: java.lang.NullPointerException: Attempt to invoke interface method 'void Ug.j$d.a(java.lang.Object)' on a null object reference
at android.app.ActivityThread.performResumeActivity(ActivityThread.java:5078)
at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:5121)
at android.app.servertransaction.ResumeActivityItem.execute(ResumeActivityItem.java:52)
at android.app.servertransaction.TransactionExecutor.executeLifecycleState(TransactionExecutor.java:190)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:105)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2613)
at android.os.Handler.dispatchMessage(Handler.java:110)
at android.os.Looper.loop(Looper.java:219)
at android.app.ActivityThread.main(ActivityThread.java:8668)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:513)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1109)
Steps to reproduce.
I can't reproduce it on my own, it's some of my users that have reported this and i saw the Trace in firebase crashlytics.
the issue description is the analysis from Gemini but i am not sure if it's device-specific or actionnable on your side.
Thanks for any insight !
What is the expected result?
The app should not crash
Did you try our example app?
No
Is it reproducible in the example app?
No
Reproducible in which OS?
Android
Flutter/Dart Version?
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.35.6, on macOS 26.0.1 25A362 darwin-arm64, locale fr-FR)
[✓] Android toolchain - develop for Android devices (Android SDK version 36.1.0)
[✓] Xcode - develop for iOS and macOS (Xcode 26.0.1)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2025.1)
[✓] VS Code (version 1.105.1)
[✓] Connected device (0 available)
[✓] Network resources
• No issues found!
Plugin Version?
google_mlkit_document_scanner: ^0.4.0