microg/GmsCore · error · IllegalArgumentException

Notification responsiveness should be nonnegative.

Error message

Notification responsiveness should be nonnegative.

What it means

notificationResponsiveness defaults to -1/invalid negative in this builder; build() requires it to be nonnegative because it controls how often the system checks for geofence transitions. A negative value is meaningless, so IllegalArgumentException is thrown.

Source

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

        /**
         * Creates a geofence object.
         *
         * @throws IllegalArgumentException if any parameters are not set or out of range
         */
        public Geofence build() throws IllegalArgumentException {
            if (requestId == null) {
                throw new IllegalArgumentException("Request ID not set.");
            } else if (transitionTypes == 0) {
                throw new IllegalArgumentException("Transition types not set.");
            } else if ((transitionTypes & GEOFENCE_TRANSITION_DWELL) > 0 && loiteringDelay < 0) {
                throw new IllegalArgumentException("Non-negative loitering delay needs to be set when transition types include GEOFENCE_TRANSITION_DWELLING.");
            } else if (expirationTime == Long.MIN_VALUE) {
                throw new IllegalArgumentException("Expiration not set.");
            } else if (regionType == -1) {
                throw new IllegalArgumentException("Geofence region not set.");
            } else if (notificationResponsiveness < 0) {
                throw new IllegalArgumentException("Notification responsiveness should be nonnegative.");
            } else {
                return new ParcelableGeofence(requestId, expirationTime, regionType, latitude, longitude, radius, transitionTypes, notificationResponsiveness, loiteringDelay);
            }
        }

        /**
         * Sets the region of this geofence. The geofence represents a circular area on a flat, horizontal plane.
         *
         * @param latitude  latitude in degrees, between -90 and +90 inclusive
         * @param longitude longitude in degrees, between -180 and +180 inclusive
         * @param radius    radius in meters
         */
        public Builder setCircularRegion(@FloatRange(from = -90.0d, to = 90.0d) double latitude, @FloatRange(from = -180.0d, to = 180.0d) double longitude, @FloatRange(from = 0.0d, fromInclusive = false) float radius) {
            this.regionType = 1;
            this.latitude = latitude;
            this.longitude = longitude;
            this.radius = radius;
            return this;

View on GitHub (pinned to 157c9d86ac)

Solutions

  1. Call setNotificationResponsiveness() with a nonnegative millisecond value (e.g. 30000), or omit the call entirely to use the default
  2. Clamp or validate any dynamically computed responsiveness value before passing it

Example fix

// before
int responsiveness = config.getInt("responsiveness", -1);
builder.setNotificationResponsiveness(responsiveness);
Geofence fence = builder.build(); // throws
// after
int responsiveness = Math.max(0, config.getInt("responsiveness", 0));
builder.setNotificationResponsiveness(responsiveness);
Geofence fence = builder.build();
Defensive patterns

Strategy: validation

Validate before calling

if (responsivenessMillis < 0) responsivenessMillis = 0; // 0 = default

Type guard

static boolean isValidResponsiveness(long v) { return v >= 0; }

Try / catch

try { return builder.build(); } catch (IllegalArgumentException e) { if (e.getMessage().contains("responsiveness")) { builder.setNotificationResponsiveness(0); return builder.build(); } throw e; }

Prevention

When it happens

Trigger: Calling build() after calling setNotificationResponsiveness(int) with a negative value (the field must be >= 0; 0 means use the default).

Common situations: Passing an uninitialized or computed-negative value (e.g. from a config defaulting to -1); misunderstanding that 0 is allowed while -1 is not.

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/171c9675d3a7d351. Report an issue: GitHub.