microg/GmsCore · error · IllegalArgumentException

minUpdateIntervalMillis must be greater than or equal to 0,

Error message

minUpdateIntervalMillis must be greater than or equal to 0, or IMPLICIT_MIN_UPDATE_INTERVAL

What it means

LocationRequest.Builder.setMinUpdateIntervalMillis() accepts values >= 0 or the special sentinel IMPLICIT_MIN_UPDATE_INTERVAL (-1); anything else is rejected. The library throws this IllegalArgumentException for negative intervals other than the sentinel.

Source

Thrown at play-services-location/src/main/java/com/google/android/gms/location/LocationRequest.java:797

            this.minUpdateDistanceMeters = minUpdateDistanceMeters;
            return this;
        }

        /**
         * Sets the fastest allowed interval of location updates. Location updates may arrive faster than the desired interval
         * ({@link #setIntervalMillis(long)}), but will never arrive faster than specified here.
         * <p>
         * This may be set to the special value {@link #IMPLICIT_MIN_UPDATE_INTERVAL} in which case the minimum update interval will
         * be the same as the interval. {@link FusedLocationProviderClient} APIs make some allowance for jitter with the minimum
         * update interval, so clients need not worry about location updates that arrive a couple milliseconds too early being
         * rejected.
         * <p>
         * The default value is {@link #IMPLICIT_MIN_UPDATE_INTERVAL}.
         */
        @NonNull
        public Builder setMinUpdateIntervalMillis(long minUpdateIntervalMillis) {
            if (minUpdateIntervalMillis < 0 && minUpdateIntervalMillis != IMPLICIT_MIN_UPDATE_INTERVAL)
                throw new IllegalArgumentException("minUpdateIntervalMillis must be greater than or equal to 0, or IMPLICIT_MIN_UPDATE_INTERVAL");
            this.minUpdateIntervalMillis = minUpdateIntervalMillis;
            return this;
        }

        @NonNull
        @Deprecated
        @PublicApi(exclude = true)
        public Builder setModuleId(@Nullable String moduleId) {
            this.moduleId = moduleId;
            return this;
        }

        /**
         * Sets the {@link Priority} of the location request.
         * <p>
         * The default value is {@link Priority#PRIORITY_BALANCED_POWER_ACCURACY}.
         */
        @NonNull

View on GitHub (pinned to 157c9d86ac)

Solutions

  1. Pass a non-negative millisecond value, or use the constant LocationRequest.IMPLICIT_MIN_UPDATE_INTERVAL.
  2. Clamp negative computed intervals to 0 before calling.
  3. Use the IMPLICIT_MIN_UPDATE_INTERVAL constant instead of a raw -1/negative literal.
  4. Omit the call to accept the default (IMPLICIT_MIN_UPDATE_INTERVAL).

Example fix

// before
builder.setMinUpdateIntervalMillis(-1000L);
// after
builder.setMinUpdateIntervalMillis(Math.max(0L, minIntervalMillis));
// or explicitly: builder.setMinUpdateIntervalMillis(LocationRequest.IMPLICIT_MIN_UPDATE_INTERVAL);
Defensive patterns

Strategy: validation

Validate before calling

if (minUpdateIntervalMillis < 0 && minUpdateIntervalMillis != LocationRequest.IMPLICIT_MIN_UPDATE_INTERVAL) {
    throw new IllegalArgumentException("invalid minUpdateIntervalMillis");
}
builder.setMinUpdateIntervalMillis(minUpdateIntervalMillis);

Try / catch

try {
    builder.setMinUpdateIntervalMillis(interval);
} catch (IllegalArgumentException e) {
    builder.setMinUpdateIntervalMillis(LocationRequest.IMPLICIT_MIN_UPDATE_INTERVAL);
}

Prevention

When it happens

Trigger: Calling setMinUpdateIntervalMillis(long) with a negative long that is not LocationRequest.IMPLICIT_MIN_UPDATE_INTERVAL, e.g. -1000 or a miscalculated interval.

Common situations: Confusing IMPLICIT_MIN_UPDATE_INTERVAL (-1) with arbitrary negative values, computing an interval as a difference that came out negative, or copying a sentinel incorrectly as a literal -2 or similar.

Understand the failure class

Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.

Related errors


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