microg/GmsCore · error · IllegalArgumentException

Invalid

Error message

Invalid 

What it means

Validation in GoogleCloudMessaging.send (the 'Invalid ' message family): a required message attribute such as the message id is null, empty, or malformed, so the message is rejected before transmission.

Source

Thrown at play-services-gcm/src/main/java/com/google/android/gms/gcm/GoogleCloudMessaging.java:239

     * <a href="http://developer.android.com/google/gcm/index.html">GCM Developers Guide</a>.</p>
     *
     * @param to         string identifying the receiver of the message in the format of
     *                   <code>SENDER_ID@gcm.googleapis.com</code>. The <code>SENDER_ID</code> should be one of the sender
     *                   IDs used when calling  {@link com.google.android.gms.iid.InstanceID#getToken(java.lang.String, java.lang.String)}
     * @param msgId      ID of the message. This is generated by the application. It must be
     *                   unique for each message. This allows error callbacks and debugging.
     * @param timeToLive If 0, we'll attempt to send immediately and return an
     *                   error if we're not connected. Otherwise, the message will be queued.
     *                   As for server-side messages, we don't return an error if the message has been
     *                   dropped because of TTL—this can happen on the server side, and it would require
     *                   extra communication.
     * @param data       key/value pairs to be sent. Values must be String, any other type will
     *                   be ignored.
     * @throws IllegalArgumentException
     * @throws IOException
     */
    public void send(String to, String msgId, long timeToLive, Bundle data) throws IOException {
        if (TextUtils.isEmpty(to)) throw new IllegalArgumentException("Invalid 'to'");

        if (isLegacyFallback()) {
            Bundle extras = new Bundle();
            for (String key : data.keySet()) {
                Object o = extras.get(key);
                if (o instanceof String) {
                    extras.putString("gcm." + key, (String) o);
                }
            }
            extras.putString(EXTRA_SEND_TO, to);
            extras.putString(EXTRA_MESSAGE_ID, msgId);
            InstanceID.getInstance(context).requestToken("GCM", "upstream", extras);
        } else {
            Bundle extras = data != null ? new Bundle(data) : new Bundle();
            extras.putString(EXTRA_SEND_TO, to);
            extras.putString(EXTRA_SEND_FROM, getFrom(to));
            extras.putString(EXTRA_MESSAGE_ID, msgId);
            extras.putLong(EXTRA_TTL, timeToLive);

View on GitHub (pinned to 157c9d86ac)

Solutions

  1. Supply a unique non-empty msgId for every send() call
  2. Validate the receiver and message fields before calling send
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at play-services-gcm/src/main/java/com/google/android/gms/gcm/GoogleCloudMessaging.java:239 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/ab2095c09e018280. Report an issue: GitHub.