Search code examples
androidgoogle-mapssupportmapfragmentmapfragment

Cannot find supportMapFragment.getMapSync()


I want to use supportMapFragment, which I have specified in my XML. Since supportMapFragment.getMap() is deprecated, supportMapFragment.getMapSync() is to be used. As per docs

However, I cannot find the method supportMapFragment.getMapAsynSync() in the SupportMapFragment class, there is only getMap() to be found.

I have the 24.4.1 version of Android SDK tools installed. How do I get supportMapFragment.getMapAsynSync() ??


Solution

  • Use getSupportFragmentManager()

    SupportMapFragment supportMapFragment = (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map);
     supportMapFragment.getMap();
    

    There is no method called getMapSync() but there is getMapAsync()

    supportMapFragment.getMapAsync();
    

    And also update your play service to com.google.android.gms:play-services:8.1.0' in gradle