2

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() ??

rgv
  • 1,186
  • 1
  • 17
  • 39

1 Answers1

4

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

Pavan Bilagi
  • 1,618
  • 1
  • 18
  • 23
  • Sorry, I meant getMapAsync(), see edit. Also, I am using getSupportFragmentManager and I want to use the method getMapAsync(), because getMap() doesn't guarantee a non- null object immediately. My problem is that I cannot find the getMapAsync() method in SupportMapFragment class for some strange reason. It is supposed to be there, but it isn't. – rgv Dec 11 '15 at 04:40
  • I don't believe it makes any difference. The issue is not in the code. The issue is that I have SupportFragmentManager class, which is deprecated. I updated my library to the latest, but cannot find the method in the google class, regardless of my code. – rgv Dec 11 '15 at 04:44
  • 1
    what is your gms paly service version ? i have used 8.1.0 in my gradle , it works fine for me 'com.google.android.gms:play-services:8.1.0' I also used 24.4.1 Sdk tool – Pavan Bilagi Dec 11 '15 at 04:51
  • Thanks! I updated my Play service version and the issue was solved, please edit your answer so I can accept it. – rgv Dec 11 '15 at 17:30