microg/GmsCore · error · UnsupportedOperationException

onCreateView not allowed on MapViewDelegate

Error message

onCreateView not allowed on MapViewDelegate

What it means

MapViewDelegate extends the lifecycle delegate of MapView but deliberately does not support onCreateView: the MapView manages its own view hierarchy through the container passed to the delegate, so an external inflater-based view creation is a programming error. Calling it throws UnsupportedOperationException unconditionally. This mirrors the restriction that view creation must go through MapView itself, not the delegate.

Source

Thrown at play-services-maps/src/main/java/org/microg/gms/maps/MapViewDelegate.java:36

import com.google.android.gms.maps.OnMapReadyCallback;
import com.google.android.gms.maps.internal.IGoogleMapDelegate;
import com.google.android.gms.maps.internal.IMapViewDelegate;
import com.google.android.gms.maps.internal.IOnMapReadyCallback;
import com.google.android.gms.maps.model.RuntimeRemoteException;

public class MapViewDelegate implements MapLifecycleDelegate {
    private final ViewGroup container;
    private final IMapViewDelegate delegate;
    private View view;

    public MapViewDelegate(ViewGroup container, IMapViewDelegate delegate) {
        this.container = container;
        this.delegate = delegate;
    }

    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup parent, @Nullable Bundle savedInstanceState) {
        throw new UnsupportedOperationException("onCreateView not allowed on MapViewDelegate");
    }

    @Override
    public void onCreate(@Nullable Bundle savedInstanceState) {
        try {
            Bundle temp = new Bundle();
            MapsBundleHelper.transfer(savedInstanceState, temp);
            delegate.onCreate(temp);
            MapsBundleHelper.transfer(temp, savedInstanceState);
            view = (View) ObjectWrapper.unwrap(delegate.getView());
            container.removeAllViews();
            container.addView(view);
        } catch (RemoteException e) {
            throw new RuntimeRemoteException(e);
        }
    }

    @Override

View on GitHub (pinned to 157c9d86ac)

Solutions

  1. Do not call onCreateView on MapViewDelegate; use MapView (or MapFragment) to create the map view.
  2. In a Fragment, inflate/place a MapView yourself and forward only onCreate/onStart/onResume/onPause/onStop/onDestroy/onSaveInstanceState/onLowMemory to it.
  3. If you hold a delegate from MapView, only invoke the lifecycle methods MapView documents as supported.
  4. Check for a library version change: code that relied on this method working will never work; restructure the call site.

Example fix

// before
@Override
public View onCreateView(LayoutInflater inf, ViewGroup p, Bundle s) {
    return delegate.onCreateView(inf, p, s); // always throws
}
// after
@Override
public View onCreateView(LayoutInflater inf, ViewGroup p, Bundle s) {
    mapView.onCreate(s);
    return mapView; // MapView already inflated via MapView(inflater, attrs)
}
Defensive patterns

Strategy: type-guard

Type guard

public static boolean supportsViewCreation(LifecycleDelegate d) {
    return !(d instanceof MapViewDelegate);
}

Try / catch

try {
    view = delegate.onCreateView(inflater, parent, savedInstanceState);
} catch (UnsupportedOperationException e) {
    view = mapView; // fall back to the owning MapView
}

Prevention

When it happens

Trigger: Calling mapViewDelegate.onCreateView(inflater, parent, savedInstanceState) directly, or using MapViewDelegate in a custom fragment/adapter where a Fragment's onCreateView implementation forwards to the delegate instead of using MapView.

Common situations: Migrating code written against the Google Maps SDK's internal delegate APIs to microG, embedding the map in a Fragment with copy-pasted lifecycle plumbing, or reflection-based frameworks calling all LifecycleDelegate methods.

Understand the failure class

Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.

Related errors


AI-assisted analysis of microg/GmsCore@157c9d86ac (2026-09-06). Data as JSON: /api/errors/b0ac4cdd6e1930eb. Report an issue: GitHub.