{"record":{"id":"7ef32308b4ed3e45","repo":"microg/GmsCore","slug":"cameraupdatefactory-is-not-initialized-7ef323","errorCode":null,"errorMessage":"CameraUpdateFactory is not initialized","messagePattern":"CameraUpdateFactory is not initialized","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"play-services-maps/src/main/java/com/google/android/gms/maps/model/BitmapDescriptorFactory.java","lineNumber":21,"sourceCode":" * SPDX-License-Identifier: Apache-2.0\n */\n\npackage com.google.android.gms.maps.model;\n\nimport androidx.annotation.NonNull;\nimport com.google.android.gms.maps.CameraUpdateFactory;\nimport com.google.android.gms.maps.internal.ICameraUpdateFactoryDelegate;\nimport com.google.android.gms.maps.model.internal.IBitmapDescriptorFactoryDelegate;\nimport org.microg.gms.common.Hide;\n\npublic class BitmapDescriptorFactory {\n    private static IBitmapDescriptorFactoryDelegate delegate;\n    @Hide\n    public static void setDelegate(@NonNull IBitmapDescriptorFactoryDelegate delegate) {\n        BitmapDescriptorFactory.delegate = delegate;\n    }\n    private static IBitmapDescriptorFactoryDelegate getDelegate() {\n        if (delegate == null) throw new IllegalStateException(\"CameraUpdateFactory is not initialized\");\n        return delegate;\n    }\n}\n","sourceCodeStart":3,"sourceCodeEnd":25,"githubUrl":"https://github.com/microg/GmsCore/blob/157c9d86ac46c195a86c2f15ab55c84036223f95/play-services-maps/src/main/java/com/google/android/gms/maps/model/BitmapDescriptorFactory.java#L3-L25","documentation":"BitmapDescriptorFactory also delegates to a backend-supplied IBitmapDescriptorFactoryDelegate installed via setDelegate. getDelegate() throws IllegalStateException (with the same, slightly misleading message 'CameraUpdateFactory is not initialized') when no map backend registered, so any defaultMarker()/fromResource() style call fails.","triggerScenarios":"Calling BitmapDescriptorFactory.defaultMarker(), fromResource(), fromBitmap(), etc. before a map backend initialized (no setDelegate call), such as building marker icons in a ViewModel or before MapsInitializer runs.","commonSituations":"Pre-computing marker icons before the map loads; running unit tests without a fake delegate; missing microG maps backend so neither factory delegate is registered.","solutions":["Initialize the map view/backend (MapsInitializer / map fragment) before using BitmapDescriptorFactory","Ensure the microG maps backend is installed so its init calls BitmapDescriptorFactory.setDelegate(...)","In tests, install a mock IBitmapDescriptorFactoryDelegate via BitmapDescriptorFactory.setDelegate first"],"exampleFix":"// before\nBitmapDescriptor icon = BitmapDescriptorFactory.fromResource(R.drawable.pin); // delegate null\n// after\nmapFragment.getMapAsync(googleMap -> {\n    BitmapDescriptor icon = BitmapDescriptorFactory.fromResource(R.drawable.pin);\n    markerOptions.icon(icon);\n});","handlingStrategy":"try-catch","validationCode":"mapFragment.getMapAsync(googleMap -> {\n    BitmapDescriptor icon = BitmapDescriptorFactory.fromResource(R.drawable.pin);\n});","typeGuard":null,"tryCatchPattern":"try { BitmapDescriptorFactory.defaultMarker(); } catch (IllegalStateException e) { /* defer until map backend initialized */ }","preventionTips":["Build BitmapDescriptors only after map initialization (onMapReady)","Ensure a maps backend is present that calls BitmapDescriptorFactory.setDelegate","In tests, set a mock IBitmapDescriptorFactoryDelegate first"],"tags":["android","maps","initialization","bitmap"],"backgroundTag":"module-init-failed","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"}