microg/GmsCore · error · IOException
Could not find suitable preview size.
Error message
Could not find suitable preview size.
What it means
Camera negotiation failure in CameraSource.pickCameraSize: none of the camera's supported preview/picture size candidates could be matched to the requested dimensions, so no preview size can be selected on this device.
Source
Thrown at play-services-vision-common/src/main/java/com/google/android/gms/vision/CameraSource.java:405
if (sizeCandidates.size() == 0) {
for (Camera.Size previewSize : camera.getParameters().getSupportedPreviewSizes()) {
sizeCandidates.add(new SizePair(previewSize, null));
}
}
SizePair sizePair = null;
int selectedSizeOffset = Integer.MAX_VALUE;
int sizeOffset;
for (SizePair candidate : sizeCandidates) {
Size candidatePreviewSize = candidate.preview;
sizeOffset = Math.abs(candidatePreviewSize.getWidth() - requestedWidth) + Math.abs(candidatePreviewSize.getHeight() - requestedHeight);
if (sizeOffset < selectedSizeOffset) {
sizePair = candidate;
selectedSizeOffset = sizeOffset;
}
}
if (sizePair == null) throw new IOException("Could not find suitable preview size.");
return sizePair;
}
private static class SizePair {
Size preview;
Size picture;
public SizePair(Camera.Size preview, Camera.Size picture) {
this.preview = new Size(preview.width, preview.height);
if (picture != null) {
this.picture = new Size(picture.width, picture.height);
}
}
}
private class DetectorRunner implements Runnable {
private final Object lock = new Object();
private long startElapsedRealtime = SystemClock.elapsedRealtime();View on GitHub (pinned to 157c9d86ac)
Solutions
- Request a more common preview resolution (e.g. 640x480) supported by the device
- Pick the closest match manually from getSupportedPreviewSizes()
- Catch the exception and fall back to a default size or disable camera detection
Defensive patterns
Strategy: fallback
When it happens
Trigger: Thrown at play-services-vision-common/src/main/java/com/google/android/gms/vision/CameraSource.java:405 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of microg/GmsCore@157c9d86ac (2026-09-06).
Data as JSON: /api/errors/acfff5c90966f619.
Report an issue: GitHub.