microg/GmsCore · error · IllegalStateException

Missing required properties: token

Error message

Missing required properties: token

What it means

ClearTokenRequest.Builder.build() requires the token property to have been set. If setToken(...) was never called, token is null and build() throws IllegalStateException naming the missing property. This is a standard AutoValue-style 'Missing required properties' guard.

Source

Thrown at play-services-auth/src/main/java/com/google/android/gms/auth/api/identity/ClearTokenRequest.java:54

    ClearTokenRequest(@NonNull @Param(1) String token, @Nullable @Param(2) String sessionId) {
        this.token = token;
        this.sessionId = sessionId;
    }

    /**
     * Returns a new {@link ClearTokenRequest.Builder}.
     */
    public static ClearTokenRequest.Builder builder() {
        return new ClearTokenRequest.Builder() {
            @Nullable
            private String token;
            @Nullable
            private String sessionId;

            @Override
            public ClearTokenRequest build() {
                if (token == null) {
                    throw new IllegalStateException("Missing required properties: token");
                }
                return new ClearTokenRequest(token, sessionId);
            }

            @Override
            public ClearTokenRequest.Builder setToken(@NonNull String token) {
                this.token = token;
                return this;
            }

            @Override
            public ClearTokenRequest.Builder setSessionId(@Nullable String sessionId) {
                this.sessionId = sessionId;
                return this;
            }
        };
    }

View on GitHub (pinned to 157c9d86ac)

Solutions

  1. Always call setToken(...) with a non-null token before build().
  2. If the token may be absent, check it first and skip building/sending the request entirely rather than building with a null token.
  3. Log a clear message when skipping so the missing-token path is debuggable.

Example fix

// before
ClearTokenRequest req = ClearTokenRequest.builder().build();
// after
if (token == null) return; // nothing to clear
ClearTokenRequest req = ClearTokenRequest.builder().setToken(token).build();
Defensive patterns

Strategy: validation

Validate before calling

if (token == null || token.isEmpty()) { skipClearToken(); return; }

Try / catch

try { req = ClearTokenRequest.builder().setToken(token).build(); } catch (IllegalStateException e) { log.warn("ClearTokenRequest missing token", e); }

Prevention

When it happens

Trigger: Calling ClearTokenRequest.builder().build() without a prior setToken(String) call.

Common situations: Conditionally skipping setToken because the token variable was null/empty (e.g. sign-out flow where the cached token is already gone); copying builder code and dropping the setToken line.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


AI-assisted analysis of microg/GmsCore@157c9d86ac (2026-09-06). Data as JSON: /api/errors/ff9acb14b768478b. Report an issue: GitHub.