{"record":{"id":"4b064ec28abdcd23","repo":"microg/GmsCore","slug":"minupdatedistancemeters-must-be-greater-than-or-eq","errorCode":null,"errorMessage":"minUpdateDistanceMeters must be greater than or equal to 0","messagePattern":"minUpdateDistanceMeters must be greater than or equal to 0","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"play-services-location/src/main/java/com/google/android/gms/location/LocationRequest.java","lineNumber":778,"sourceCode":"         * The default value is {@link Integer#MAX_VALUE}.\n         */\n        @NonNull\n        public Builder setMaxUpdates(int maxUpdates) {\n            if (maxUpdates <= 0) throw new IllegalArgumentException(\"maxUpdates must be greater than 0\");\n            this.maxUpdates = maxUpdates;\n            return this;\n        }\n\n        /**\n         * Sets the minimum distance required between consecutive location updates. If a derived location update is not at least\n         * the specified distance away from the previous location update delivered to the client, it will not be delivered. This may\n         * also allow additional power savings under some circumstances.\n         * <p>\n         * The default value is 0.\n         */\n        @NonNull\n        public Builder setMinUpdateDistanceMeters(float minUpdateDistanceMeters) {\n            if (minUpdateDistanceMeters < 0) throw new IllegalArgumentException(\"minUpdateDistanceMeters must be greater than or equal to 0\");\n            this.minUpdateDistanceMeters = minUpdateDistanceMeters;\n            return this;\n        }\n\n        /**\n         * Sets the fastest allowed interval of location updates. Location updates may arrive faster than the desired interval\n         * ({@link #setIntervalMillis(long)}), but will never arrive faster than specified here.\n         * <p>\n         * This may be set to the special value {@link #IMPLICIT_MIN_UPDATE_INTERVAL} in which case the minimum update interval will\n         * be the same as the interval. {@link FusedLocationProviderClient} APIs make some allowance for jitter with the minimum\n         * update interval, so clients need not worry about location updates that arrive a couple milliseconds too early being\n         * rejected.\n         * <p>\n         * The default value is {@link #IMPLICIT_MIN_UPDATE_INTERVAL}.\n         */\n        @NonNull\n        public Builder setMinUpdateIntervalMillis(long minUpdateIntervalMillis) {\n            if (minUpdateIntervalMillis < 0 && minUpdateIntervalMillis != IMPLICIT_MIN_UPDATE_INTERVAL)","sourceCodeStart":760,"sourceCodeEnd":796,"githubUrl":"https://github.com/microg/GmsCore/blob/157c9d86ac46c195a86c2f15ab55c84036223f95/play-services-location/src/main/java/com/google/android/gms/location/LocationRequest.java#L760-L796","documentation":"LocationRequest.Builder.setMinUpdateDistanceMeters() requires a non-negative distance in meters; negative values are invalid. The library throws this IllegalArgumentException when the argument is negative, because a negative minimum update distance has no physical meaning.","triggerScenarios":"Calling setMinUpdateDistanceMeters(float) with any value < 0, e.g. a sign error or a computed delta that went negative.","commonSituations":"Subtracting distances in the wrong order, reusing a signed offset variable as a distance, or parsing user input without checking sign.","solutions":["Pass a non-negative float (0 disables the distance constraint).","Clamp with Math.max(0, distance) before building.","Verify the sign of the computed distance.","Omit the call if you want the default of 0."],"exampleFix":"// before\nbuilder.setMinUpdateDistanceMeters(-10f);\n// after\nbuilder.setMinUpdateDistanceMeters(Math.max(0f, minDistanceMeters));","handlingStrategy":"validation","validationCode":"if (minUpdateDistanceMeters < 0) { throw new IllegalArgumentException(\"distance must be >= 0\"); }\nbuilder.setMinUpdateDistanceMeters(minUpdateDistanceMeters);","typeGuard":null,"tryCatchPattern":"try {\n    builder.setMinUpdateDistanceMeters(distance);\n} catch (IllegalArgumentException e) {\n    builder.setMinUpdateDistanceMeters(0f);\n}","preventionTips":["Clamp computed distances with Math.max(0f, value)","Check the sign of variables reused as distances","Omit the setter to accept the default of 0"],"tags":["android","location","argument-validation"],"backgroundTag":"invalid-argument-value","analyzedSha":"157c9d86ac46c195a86c2f15ab55c84036223f95","analyzedAt":"2026-09-06T17:27:33.892Z","contentChangedAt":"2026-09-06T17:27:33.892Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}