{"record":{"id":"ecefb1e744582f5a","repo":"microg/GmsCore","slug":"resources-have-not-been-initialized","errorCode":null,"errorMessage":"Resources have not been initialized","messagePattern":"Resources have not been initialized","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"play-services-maps/core/vtm/src/main/java/org/microg/gms/maps/vtm/ResourcesContainer.java","lineNumber":30,"sourceCode":" * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage org.microg.gms.maps.vtm;\n\nimport android.content.res.Resources;\n\npublic class ResourcesContainer {\n    private static Resources resources;\n\n    public static void set(Resources resources) {\n        ResourcesContainer.resources = resources;\n    }\n\n    public static Resources get() {\n        if (resources == null) {\n            throw new IllegalStateException(\"Resources have not been initialized\");\n        } else {\n            return resources;\n        }\n    }\n}\n","sourceCodeStart":12,"sourceCodeEnd":36,"githubUrl":"https://github.com/microg/GmsCore/blob/157c9d86ac46c195a86c2f15ab55c84036223f95/play-services-maps/core/vtm/src/main/java/org/microg/gms/maps/vtm/ResourcesContainer.java#L12-L36","documentation":"ResourcesContainer is a static holder that the embedding app (or map backend) must initialize via ResourcesContainer.set(Resources) before any code needs to resolve resources. get() throws IllegalStateException when set() was never called, because the library cannot inflate/inflate-locate map resources otherwise.","triggerScenarios":"Using the vtm maps backend (GoogleMapImpl and friends) without having called ResourcesContainer.set(context.getResources()) during app or backend initialization — e.g. using maps in a process that skips the usual initialization entry point.","commonSituations":"Running in a separate process (push, content provider) where the Application init code did not run; calling map APIs from an instrumented test; missing microG/extension initialization in a custom ROM integration.","solutions":["Call ResourcesContainer.set(context.getResources()) (typically in Application.onCreate) before using map APIs","Ensure initialization also runs for every process declared in the manifest","If embedding microG itself, verify the maps backend init path sets the container"],"exampleFix":"// before\nGoogleMap map = getMap(); // ResourcesContainer not set\n// after\nResourcesContainer.set(getApplicationContext().getResources());\nGoogleMap map = getMap();","handlingStrategy":"validation","validationCode":"// initialize once before using map APIs\nif (ApplicationContextHolder.get() != null) {\n    ResourcesContainer.set(ApplicationContextHolder.get().getResources());\n}","typeGuard":null,"tryCatchPattern":"try { Resources r = ResourcesContainer.get(); } catch (IllegalStateException e) { ResourcesContainer.set(context.getResources()); }","preventionTips":["Call ResourcesContainer.set(...) in Application.onCreate","Ensure init code runs in every declared process (providers, push services)","Verify the maps backend initialization path executes in tests too"],"tags":["android","maps","initialization","resources"],"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"}