{"record":{"id":"6b80dea552fbca28","repo":"microg/GmsCore","slug":"no-detector-supplied","errorCode":null,"errorMessage":"No detector supplied.","messagePattern":"No detector supplied\\.","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"play-services-vision-common/src/main/java/com/google/android/gms/vision/CameraSource.java","lineNumber":192,"sourceCode":"            if (camera != null) {\n                camera.takePicture(shutter::onShutter, null, null, (data, camera) -> jpeg.onPictureTaken(data));\n            }\n        }\n    }\n\n    /**\n     * Builder for configuring and creating an associated camera source.\n     */\n    public static class Builder {\n        private CameraSource cameraSource = new CameraSource();\n\n        /**\n         * Creates a camera source builder with the supplied context and detector.\n         * Camera preview images will be streamed to the associated detector upon starting the camera source.\n         */\n        public Builder(Context context, Detector<?> detector) {\n            if (context == null) throw new IllegalArgumentException(\"No context supplied.\");\n            if (detector == null) throw new IllegalArgumentException(\"No detector supplied.\");\n            this.cameraSource.context = context;\n            this.cameraSource.detector = detector;\n        }\n\n        /**\n         * Creates an instance of the camera source.\n         */\n        public CameraSource build() {\n            return cameraSource;\n        }\n\n        /**\n         * Sets whether to enable camera auto focus. If set to false (default), the camera's default focus setting is used. If set to true, a continuous video focus setting is used (if supported by the camera hardware).\n         * Default: false.\n         */\n        public Builder setAutoFocusEnabled(boolean autoFocusEnabled) {\n            this.cameraSource.autoFocusEnabled = autoFocusEnabled;\n            return this;","sourceCodeStart":174,"sourceCodeEnd":210,"githubUrl":"https://github.com/microg/GmsCore/blob/157c9d86ac46c195a86c2f15ab55c84036223f95/play-services-vision-common/src/main/java/com/google/android/gms/vision/CameraSource.java#L174-L210","documentation":"CameraSource.Builder's constructor throws IllegalArgumentException when the supplied Detector is null. The detector processes camera preview frames, so the builder fails fast rather than producing a CameraSource that cannot do anything at start().","triggerScenarios":"Calling new CameraSource.Builder(context, null) — commonly because detector construction failed silently, a factory method returned null, or the detector was conditionally created for a feature that is disabled.","commonSituations":"Lazy-initialized detector field still null at builder time; barcode/face detector creation skipped when dependencies (e.g. model download) failed; wrong variable passed.","solutions":["Create the detector before building the CameraSource and verify it is non-null","Handle detector-creation failures explicitly instead of passing the null result downstream","Check the order of initialization so the detector exists before the builder call","Wrap in a null check that produces a clearer app-level error"],"exampleFix":"// before\nDetector<?> detector = maybeCreateDetector(); // may return null\nCameraSource source = new CameraSource.Builder(context, detector).build();\n// after\nDetector<?> detector = maybeCreateDetector();\nif (detector == null) throw new IllegalStateException(\"Detector unavailable\");\nCameraSource source = new CameraSource.Builder(context, detector).build();","handlingStrategy":"validation","validationCode":"if (detector == null) throw new IllegalStateException(\"Detector must be created before building CameraSource\");","typeGuard":"boolean canBuildCameraSource(Context ctx, Detector<?> d) { return ctx != null && d != null; }","tryCatchPattern":"try {\n    CameraSource.Builder b = new CameraSource.Builder(context, detector);\n} catch (IllegalArgumentException e) {\n    // detector creation failed upstream; surface the real cause\n}","preventionTips":["Create detectors eagerly and handle their failure paths explicitly","Don't pass lazily-initialized fields that may still be null","Log why detector creation returned null"],"tags":["vision","camera","null-check","java"],"backgroundTag":"null-argument","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"}