microg/GmsCore · error · IOException

ERROR_MAIN_THREAD

ERROR_MAIN_THREAD

Error message

ERROR_MAIN_THREAD

What it means

Threading guard in InstanceID.deleteToken: the token operation was invoked on the main thread, which InstanceID forbids; the error string 'ERROR_MAIN_THREAD' is surfaced in the failure result rather than thrown directly.

Source

Thrown at play-services-iid/src/main/java/com/google/android/gms/iid/InstanceID.java:134

    }

    /**
     * Revokes access to a scope (action) for an entity previously
     * authorized by {@link com.google.android.gms.iid.InstanceID#getToken(java.lang.String, java.lang.String)}.
     * <p/>
     * Do not call this function on the main thread.
     *
     * @param authorizedEntity Entity that must no longer have access.
     * @param scope            Action that entity is no longer authorized to perform.
     * @throws IOException if the request fails.
     */
    public void deleteToken(String authorizedEntity, String scope) throws IOException {
        deleteToken(authorizedEntity, scope, null);
    }

    @PublicApi(exclude = true)
    public void deleteToken(String authorizedEntity, String scope, Bundle extras) throws IOException {
        if (Looper.getMainLooper() == Looper.myLooper()) throw new IOException(ERROR_MAIN_THREAD);

        storeInstance.delete(subtype, authorizedEntity, scope);

        if (extras == null) extras = new Bundle();
        extras.putString(EXTRA_SENDER, authorizedEntity);
        extras.putString(EXTRA_SUBSCIPTION, authorizedEntity);
        extras.putString(EXTRA_DELETE, "1");
        extras.putString("X-" + EXTRA_DELETE, "1");
        extras.putString(EXTRA_SUBTYPE, TextUtils.isEmpty(subtype) ? authorizedEntity : subtype);
        extras.putString("X-" + EXTRA_SUBTYPE, TextUtils.isEmpty(subtype) ? authorizedEntity : subtype);
        if (scope != null) extras.putString(EXTRA_SCOPE, scope);

        rpc.handleRegisterMessageResult(rpc.sendRegisterMessageBlocking(extras, getKeyPair()));
    }

    /**
     * Returns time when instance ID was created.
     *

View on GitHub (pinned to 157c9d86ac)

Solutions

  1. Call deleteToken/getToken from a background thread or coroutine
  2. Retry once the operation runs off the main thread
Defensive patterns

Strategy: retry

When it happens

Trigger: Thrown at play-services-iid/src/main/java/com/google/android/gms/iid/InstanceID.java:134 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/a9ff2d4fa803215f. Report an issue: GitHub.