Android – SupportMapFragment with GoogleMaps API 2.0 giving IllegalArgumentException

You can fix this, if you delete all nested fragments in onDestroyView(). Don’t know if it is a proper solution.

public void onDestroyView() {
   super.onDestroyView(); 
   Fragment fragment = (getFragmentManager().findFragmentById(R.id.map));   
   FragmentTransaction ft = getActivity().getSupportFragmentManager().beginTransaction();
   ft.remove(fragment);
   ft.commit();
}

And inflating them as usual in onCreateView()

public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    return inflater.inflate(R.layout.map, container, false);
}

Leave a Comment