microg/GmsCore · error · IllegalArgumentException

SecurePaymentsData.value must not be null

Error message

SecurePaymentsData.value must not be null

What it means

SecurePaymentsData's constructor requires a non-null value String and throws IllegalArgumentException when it is null. The value is parcelled to Google Play services, which cannot accept a null payload for this field.

Source

Thrown at play-services-base/src/main/java/com/google/android/gms/wallet/firstparty/pm/SecurePaymentsData.java:31

import com.google.android.gms.common.internal.safeparcel.SafeParcelable;
import com.google.android.gms.common.internal.safeparcel.SafeParcelableCreatorAndWriter;

@SafeParcelable.Class
public class SecurePaymentsData extends AbstractSafeParcelable {
    @Field(2)
    public final int key;
    @Field(3)
    public final String value;

    @Constructor
    public SecurePaymentsData(@Param(2) int key, @Param(3) String value) {
        this.key = key;
        this.value = value;
        if (key <= 0) {
            throw new IllegalArgumentException("SecurePaymentsData.key must be > 0");
        }
        if (value == null) {
            throw new IllegalArgumentException("SecurePaymentsData.value must not be null");
        }
    }

    @Override
    public void writeToParcel(@NonNull Parcel dest, int flags) {
        CREATOR.writeToParcel(this, dest, flags);
    }

    public static final SafeParcelableCreatorAndWriter<SecurePaymentsData> CREATOR = findCreator(SecurePaymentsData.class);
}

View on GitHub (pinned to 157c9d86ac)

Solutions

  1. Ensure value is non-null before constructing
  2. Substitute an empty string if a null value is semantically acceptable
  3. Reject/repair the source record before building the object

Example fix

// before
SecurePaymentsData d = new SecurePaymentsData(key, json.optString("value", null)); // may be null
// after
String v = json.optString("value", "");
SecurePaymentsData d = new SecurePaymentsData(key, v);
Defensive patterns

Strategy: validation

Validate before calling

if (value != null) {
    SecurePaymentsData d = new SecurePaymentsData(key, value);
}

Type guard

// Java lacks null narrowing; use Objects.requireNonNull
String v = Objects.requireNonNull(value, "value required");

Try / catch

try { new SecurePaymentsData(key, value); } catch (IllegalArgumentException e) { /* default value to "" or skip */ }

Prevention

When it happens

Trigger: Calling new SecurePaymentsData(key, null), or unparcelling data where the value string was not written.

Common situations: Mapping backend responses where the value field is absent (JSON null) straight into the constructor.

Related errors


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