microg/GmsCore · error · IllegalArgumentException
Transition types not set.
Error message
Transition types not set.
What it means
Geofence.Builder.build() validates that transition types were configured before constructing the geofence. transitionTypes defaults to 0, meaning no GEOFENCE_TRANSITION_ENTER/EXIT/DWELL events were requested, so the geofence would be meaningless to monitor. The library throws IllegalArgumentException to fail fast at build time.
Source
Thrown at play-services-location/src/main/java/com/google/android/gms/location/Geofence.java:114
private double latitude;
private double longitude;
private float radius;
private long expirationTime = Long.MIN_VALUE;
private int loiteringDelay = -1;
private int notificationResponsiveness;
private String requestId;
private @TransitionTypes int transitionTypes;
/**
* 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 inclusiveView on GitHub (pinned to 157c9d86ac)
Solutions
- Call setTransitionTypes() on the builder with at least one of Geofence.GEOFENCE_TRANSITION_ENTER, GEOFENCE_TRANSITION_EXIT, or GEOFENCE_TRANSITION_DWELL before calling build()
- Verify the int value passed is a non-zero combination of the GEOFENCE_TRANSITION_* constants
Example fix
// before
Geofence fence = new Geofence.Builder()
.setRequestId("fence1")
.setCircularRegion(lat, lng, radius)
.setExpirationDuration(600000)
.build();
// after
Geofence fence = new Geofence.Builder()
.setRequestId("fence1")
.setTransitionTypes(Geofence.GEOFENCE_TRANSITION_ENTER | Geofence.GEOFENCE_TRANSITION_EXIT)
.setCircularRegion(lat, lng, radius)
.setExpirationDuration(600000)
.build(); Defensive patterns
Strategy: validation
Validate before calling
if (transitionTypes == 0) throw new IllegalStateException("Call setTransitionTypes() before build()");
Geofence fence = builder.setTransitionTypes(Geofence.GEOFENCE_TRANSITION_ENTER | Geofence.GEOFENCE_TRANSITION_EXIT).build(); Type guard
static boolean hasTransitionTypes(int t) { return t != 0; } Try / catch
try { return builder.build(); } catch (IllegalArgumentException e) { if (e.getMessage().contains("Transition types")) { builder.setTransitionTypes(Geofence.GEOFENCE_TRANSITION_ENTER | Geofence.GEOFENCE_TRANSITION_EXIT); return builder.build(); } throw e; } Prevention
- Always include setTransitionTypes() in your Geofence builder helper/wrapper
- Build geofences through a single factory method so required calls are never skipped
When it happens
Trigger: Calling Geofence.Builder.build() without calling setTransitionTypes(int) (or calling it with 0). The check fires when transitionTypes == 0.
Common situations: Copy-pasting builder snippets that omit setTransitionTypes; constructing a geofence incrementally and forgetting the transition call; refactoring where the constant passed was accidentally 0.
Understand the failure class
Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.
Related errors
- deleteAll=true but keys are provided
- invalid radius:
- invalid latitude:
- invalid longitude:
- Non-negative loitering delay needs to be set when transition
AI-assisted analysis of microg/GmsCore@157c9d86ac (2026-09-06).
Data as JSON: /api/errors/d7da7fb531c5bfee.
Report an issue: GitHub.