microg/GmsCore · error · IllegalStateException
Value is not a string.
Error message
Value is not a string.
What it means
Format guard in fitness Value.asString: the Value's format is not FORMAT_STRING, so the internal stringValue cannot be returned. It fires when a numeric- or map-formatted Value is read through the string accessor.
Source
Thrown at play-services-fitness/src/main/java/com/google/android/gms/fitness/data/Value.java:107
/**
* Returns the value of this object as a int.
*
* @throws IllegalStateException If this {@link Value} does not correspond to a {@link com.google.android.gms.fitness.data.Field#FORMAT_INT32}
*/
public int asInt() {
if (format != FORMAT_INT32) throw new IllegalStateException("Value is not a int.");
return Float.floatToRawIntBits(this.value);
}
/**
* Returns the value of this object as a string.
*
* @throws IllegalStateException If this {@link Value} does not correspond to a {@link com.google.android.gms.fitness.data.Field#FORMAT_STRING}
*/
@NonNull
public String asString() {
if (format != FORMAT_STRING) throw new IllegalStateException("Value is not a string.");
if (stringValue == null) return "";
return stringValue;
}
/**
* Clears any value currently associated with the given {@code key} in the map. This method can be used only on map values.
*
* @param key The key you're modifying.
* @deprecated Use {@link DataPoint.Builder} to construct new {@link DataPoint} instances.
*/
@Deprecated
public void clearKey(String key) {
if (format != FORMAT_MAP) throw new IllegalStateException("Value is not a map.");
if (mapValue != null) {
mapValue.remove(key);
}
}
View on GitHub (pinned to 157c9d86ac)
Solutions
- Check getFormat() == Field.FORMAT_STRING before calling asString()
- Use the accessor matching the Value's actual format
Defensive patterns
Strategy: type-guard
When it happens
Trigger: Thrown at play-services-fitness/src/main/java/com/google/android/gms/fitness/data/Value.java:107 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/933e44407cad64a9.
Report an issue: GitHub.