microg/GmsCore · error · NullPointerException

string must not be null

Error message

string must not be null

What it means

Size.parseSize(String) requires a non-null input string formatted as 'WxH' or 'W*H'; it throws NullPointerException when the argument is null before parsing can begin. The faulting input is a null string passed to parseSize.

Source

Thrown at play-services-base/src/main/java/com/google/android/gms/common/images/Size.java:92

        return result;
    }

    /**
     * Parses the specified string as a size value.
     * <p>
     * The ASCII characters {@code \}{@code u002a} ('*') and {@code \}{@code u0078} ('x') are recognized as separators between the width and height.
     * <p>
     * For any {@code Size s}: {@code Size.parseSize(s.toString()).equals(s)}. However, the method also handles sizes expressed in the following forms:
     * <p>
     * "width{@code x}height" or "width{@code *}height" => new Size(width, height), where width and height are string integers potentially containing a sign, such as "-10", "+7" or "5".
     *
     * @param string the string representation of a size value.
     * @return the size value represented by {@code string}.
     * @throws NumberFormatException if {@code string} cannot be parsed as a size value.
     * @throws NullPointerException  if {@code string} was null
     */
    public static Size parseSize(String string) {
        if (string == null) throw new NullPointerException("string must not be null");
        int split = string.indexOf('*');
        if (split < 0) split = string.indexOf('x');
        if (split < 0) throw new NumberFormatException("Invalid Size: \"" + string + "\"");
        return new Size(Integer.parseInt(string.substring(0, split)), Integer.parseInt(string.substring(split + 1)));
    }

    /**
     * Return the size represented as a string with the format {@code "WxH"}
     * @return string representation of the size
     */
    @Override
    public String toString() {
        return width + "x" + height;
    }
}

View on GitHub (pinned to 157c9d86ac)

Solutions

  1. Check the input string for null before calling parseSize
  2. Skip parsing or return a default Size when the source string is null
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at play-services-base/src/main/java/com/google/android/gms/common/images/Size.java:92 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/24111af0e54b8282. Report an issue: GitHub.