{"record":{"id":"e9c7bc52961acbae","repo":"microg/GmsCore","slug":"ondestroyview-not-allowed-on-mapviewdelegate","errorCode":null,"errorMessage":"onDestroyView not allowed on MapViewDelegate","messagePattern":"onDestroyView not allowed on MapViewDelegate","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"play-services-maps/src/main/java/org/microg/gms/maps/MapViewDelegate.java","lineNumber":65,"sourceCode":"            container.removeAllViews();\n            container.addView(view);\n        } catch (RemoteException e) {\n            throw new RuntimeRemoteException(e);\n        }\n    }\n\n    @Override\n    public void onDestroy() {\n        try {\n            delegate.onDestroy();\n        } catch (RemoteException e) {\n            throw new RuntimeRemoteException(e);\n        }\n    }\n\n    @Override\n    public void onDestroyView() {\n        throw new UnsupportedOperationException(\"onDestroyView not allowed on MapViewDelegate\");\n    }\n\n    public void onEnterAmbient(Bundle bundle) {\n        try {\n            Bundle temp = new Bundle();\n            MapsBundleHelper.transfer(bundle, temp);\n            delegate.onEnterAmbient(temp);\n            MapsBundleHelper.transfer(temp, bundle);\n        } catch (RemoteException e) {\n            throw new RuntimeRemoteException(e);\n        }\n    }\n\n    public void onExitAmbient() {\n        try {\n            delegate.onExitAmbient();\n        } catch (RemoteException e) {\n            throw new RuntimeRemoteException(e);","sourceCodeStart":47,"sourceCodeEnd":83,"githubUrl":"https://github.com/microg/GmsCore/blob/157c9d86ac46c195a86c2f15ab55c84036223f95/play-services-maps/src/main/java/org/microg/gms/maps/MapViewDelegate.java#L47-L83","documentation":"MapViewDelegate.onDestroyView() is another intentionally unsupported lifecycle hook: view teardown is owned by MapView/container, not the delegate. Any invocation throws UnsupportedOperationException unconditionally. Lifecycle must be driven through MapView's onDestroy (or onDestroyView on the owning view), never directly on this delegate.","triggerScenarios":"Calling mapViewDelegate.onDestroyView() directly, or a Fragment/ custom view whose onDestroyView() forwards to the delegate instead of mapView.onDestroy().","commonSituations":"Fragment-based map embedding with hand-rolled lifecycle forwarding, code copied from Google Maps internal usage, or generic lifecycle-dispatch frameworks that enumerate all LifecycleDelegate methods.","solutions":["Call mapView.onDestroy() (or the owner's view destruction) instead of delegate.onDestroyView().","Remove onDestroyView forwarding from your Fragment; let MapView handle its own teardown.","Only forward the lifecycle callbacks MapView exposes publicly.","If using MapFragment/SupportMapFragment, rely on the fragment lifecycle rather than touching delegates at all."],"exampleFix":"// before\n@Override\npublic void onDestroyView() {\n    delegate.onDestroyView(); // always throws\n}\n// after\n@Override\npublic void onDestroyView() {\n    mapView.onDestroy();\n}","handlingStrategy":"type-guard","validationCode":null,"typeGuard":"public static boolean supportsDestroyView(LifecycleDelegate d) {\n    return !(d instanceof MapViewDelegate);\n}","tryCatchPattern":"try {\n    delegate.onDestroyView();\n} catch (UnsupportedOperationException e) {\n    mapView.onDestroy(); // correct teardown path\n}","preventionTips":["Route all view teardown through MapView.onDestroy(), never the delegate.","Keep Fragment onDestroyView forwarding limited to public MapView APIs.","Avoid generic lifecycle dispatchers that call unimplemented delegate methods.","Pin lifecycle forwarding code to a reviewed list of supported MapView callbacks."],"tags":["android","maps","unsupported-operation","lifecycle"],"backgroundTag":"unsupported-operation","analyzedSha":"157c9d86ac46c195a86c2f15ab55c84036223f95","analyzedAt":"2026-09-06T17:27:33.892Z","contentChangedAt":"2026-09-06T17:27:33.892Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}