google_mlkit_face_detection: FaceDetector.processImage() crashes only in Android release (works in debug)
I'm seeing a native crash from google_mlkit_face_detection that only happens in Android release builds.
Flutter: (version)
google_mlkit_face_detection: (version)
google_mlkit_commons: (version)
camera: (version)
camera_android_camerax: (version)
Android: 16
Device: (device model)
Debug build works.
Release build crashes.
The crash occurs every time at:
final inputImage = InputImage.fromFilePath(capture.path);
final faces = await _detector.processImage(inputImage);
The image itself is valid.
Diagnostics show:
Camera initializes successfully.
takePicture() succeeds.
JPEG exists on disk.
JPEG header is valid.
Dart successfully decodes the JPEG.
InputImage.fromFilePath() succeeds.
Crash occurs only when calling FaceDetector.processImage().
Relevant log sequence:
after_takePicture
capture_file_metadata
dart_decode_completed
before_inputImage_fromFilePath
after_inputImage_fromFilePath
before_detector_processImage
PlatformException:
Attempt to invoke virtual method
'java.lang.Class java.lang.Object.getClass()'
on a null object reference
Stack trace:
PlatformException(
error,
Attempt to invoke virtual method
'java.lang.Class java.lang.Object.getClass()'
on a null object reference,
...
FaceDetector.processImage(...)
)
Storage permissions
Camera permissions
Corrupt JPEG
Invalid image path
Invalid file
InputImage.fromFilePath() creation failure
I originally suspected InputImage.fromBytes, but my current code does not use it.
Current flow is:
takePicture()
↓
JPEG saved
↓
InputImage.fromFilePath(...)
↓
FaceDetector.processImage(...)
↓
Native NPE
Debug works.
Release fails.
This strongly suggests either:
R8/minification
ML Kit native dependency issue
Android 16 compatibility issue
google_mlkit_face_detection regression
Has anyone encountered this exact release-only crash?
If this is an R8 issue, are there recommended keep rules for current ML Kit versions?