microg/GmsCore · error · IllegalArgumentException
Unsupported image format:
Error message
Unsupported image format:
What it means
Format validation in Frame.Builder.setImageData: the format argument is not one of ImageFormat.NV16, NV21, or YV12 accepted by the vision Frame, so the bytes cannot be interpreted. The offending format value is appended.
Source
Thrown at play-services-vision-common/src/main/java/com/google/android/gms/vision/Frame.java:127
public Builder setId(int id) {
this.frame.metadata.id = id;
return this;
}
/**
* Sets the image data from the supplied byte buffer, size, and format.
*
* @param data contains image byte data according to the associated format.
* @param width
* @param height
* @param format one of {@link ImageFormat#NV16}, {@link ImageFormat#NV21}, or {@link ImageFormat#YV12}.
* @throws IllegalArgumentException if the supplied data is null, or an invalid image format was supplied.
*/
public Builder setImageData(ByteBuffer data, int width, int height, int format) {
if (data == null) throw new IllegalArgumentException("Null image data supplied");
if (data.capacity() < width * height) throw new IllegalArgumentException("Invalid image data size");
if (format != ImageFormat.NV16 && format != ImageFormat.NV21 && format != ImageFormat.YV12)
throw new IllegalArgumentException("Unsupported image format: " + format);
this.frame.imageData = data;
this.frame.metadata.width = width;
this.frame.metadata.height = height;
this.frame.metadata.format = format;
return this;
}
/**
* Sets the image rotation, indicating the rotation from the upright orientation.
* <p>
* Since the camera may deliver images that are rotated (e.g., if the user holds the device upside down), specifying the rotation with the image indicates how to make the image be upright, if necessary. Some detectors may rely upon rotating the image before attempting detection, whereas others may not. In preserving the original image from the camera along with this value, the detector may choose whether to make this correction (and to assume the associated cost).
* <p>
* However, note that the detector is expected to report detection position coordinates that are relative to the upright version of the image (whether or not the image was actually rotated by the detector). The {@link Detector} will always deliver frame metadata to the {@link Detector.Processor} that indicates the dimensions and orientation of an unrotated, upright frame.
*
* @param rotation one of {@link Frame#ROTATION_0}, {@link Frame#ROTATION_90}, {@link Frame#ROTATION_180}, {@link Frame#ROTATION_270}. Has the same meaning as {@link Display#getRotation()}.
*/
public Builder setRotation(int rotation) {
this.frame.metadata.rotation = rotation;View on GitHub (pinned to 157c9d86ac)
Solutions
- Convert the image to NV21 or YV12 before calling setImageData
- Pass one of the supported ImageFormat constants
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at play-services-vision-common/src/main/java/com/google/android/gms/vision/Frame.java:127 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/690112796199dfc4.
Report an issue: GitHub.