找不到 supportMapFragment.getMapSync()

Cannot find supportMapFragment.getMapSync()

我想使用我在 XML 中指定的 supportMapFragment。 由于不推荐使用 supportMapFragment.getMap(),因此将使用 supportMapFragment.getMapSync()As per docs

但是,我在 SupportMapFragment class 中找不到方法 supportMapFragment.getMapAsynSync(),那里只能找到getMap()

我安装了 24.4.1 版本的 Android SDK 工具。 我如何获得 supportMapFragment.getMapAsynSync()

使用getSupportFragmentManager()

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

没有名为 getMapSync() 的方法,但有 getMapAsync()

supportMapFragment.getMapAsync();

并在 gradle

中将您的播放服务更新为 com.google.android.gms:play-services:8.1.0'