microg/GmsCore · error · IllegalArgumentException
Not a double type
Error message
Not a double type
What it means
Flag.getDouble() throws IllegalArgumentException("Not a double type") when the flag's dataType is not DATA_TYPE_DOUBLE. Each typed accessor in Flag validates the dataType discriminator before returning its field, so reading the double field of a flag that is not of double type fails fast instead of returning an undefined value.
Source
Thrown at play-services-phenotype/src/main/java/com/google/android/gms/phenotype/Flag.java:83
this.flagType = flagType;
}
public long getLong() {
if (dataType == DATA_TYPE_LONG)
return longValue;
throw new IllegalArgumentException("Not a long type");
}
public boolean getBool() {
if (dataType == DATA_TYPE_BOOL)
return boolValue;
throw new IllegalArgumentException("Not a boolean type");
}
public double getDouble() {
if (dataType == DATA_TYPE_DOUBLE)
return doubleValue;
throw new IllegalArgumentException("Not a double type");
}
public String getString() {
if (dataType == DATA_TYPE_STRING)
return stringValue;
throw new IllegalArgumentException("Not a String type");
}
public byte[] getBytes() {
if (dataType == DATA_TYPE_BYTES)
return bytesValue;
throw new IllegalArgumentException("Not a bytes type");
}
public static final int DATA_TYPE_LONG = 1;
public static final int DATA_TYPE_BOOL = 2;
public static final int DATA_TYPE_DOUBLE = 3;
public static final int DATA_TYPE_STRING = 4;View on GitHub (pinned to 157c9d86ac)
Solutions
- Check flag.getDataType() == Flag.DATA_TYPE_DOUBLE before calling getDouble()
- If numeric values may be long, accept DATA_TYPE_LONG and widen to double via ((double) flag.getLong())
- Switch over DATA_TYPE_* constants and handle each typed case
- Verify the server-side flag type is still double
Example fix
// before double d = flag.getDouble(); // after double d; if (flag.getDataType() == Flag.DATA_TYPE_DOUBLE) d = flag.getDouble(); else if (flag.getDataType() == Flag.DATA_TYPE_LONG) d = (double) flag.getLong(); else d = 0.0;
Defensive patterns
Strategy: type-guard
Validate before calling
if (flag.getDataType() != Flag.DATA_TYPE_DOUBLE) { throw new IllegalStateException("flag is not a double: " + flag.getDataType()); } Type guard
static boolean isDoubleFlag(Flag f) { return f != null && f.getDataType() == Flag.DATA_TYPE_DOUBLE; } Try / catch
try { double v = flag.getDouble(); } catch (IllegalArgumentException e) { log.warn("Flag type mismatch", e); v = DEFAULT_DOUBLE; } Prevention
- Check dataType == DATA_TYPE_DOUBLE before getDouble()
- Accept DATA_TYPE_LONG as a numeric fallback when widening is acceptable
- Keep numeric flag handling in a shared utility
- Verify flag type in the phenotype console after edits
When it happens
Trigger: Calling Flag.getDouble() on a Flag whose dataType is DATA_TYPE_LONG (1), DATA_TYPE_BOOL (2), DATA_TYPE_STRING (4), or DATA_TYPE_BYTES (5) instead of DATA_TYPE_DOUBLE (3).
Common situations: Server experiment changed a flag from double to long or string; generic flag-parsing code that assumes a fixed type per field; migrating from another config library where numbers were uniformly doubles.
Understand the failure class
Background: Type mismatch errors: IllegalArgumentException, TypeError and type guards across 150 open-source libraries — this error's family across 150 libraries.
Related errors
AI-assisted analysis of microg/GmsCore@157c9d86ac (2026-09-06).
Data as JSON: /api/errors/f84fc2acc489d732.
Report an issue: GitHub.