The current Android Google Maps API requires you call mapFragment.getMapAsync
with a OnMapReadyCallback
before you can access the GoogleMap
. I assumed that once you had the GoogleMap
it would then be safe to call moveCamera()
but I was seeing crash reports with an IllegalStateException
which said Map size can't be 0. Most likely, layout has not yet occured for the map view
.
So I tried adding a ViewTreeObserver.OnPreDrawListener
, and moving the moveCamera()
call to the onPreDraw
method, as the docs for that say "At this point, all views in the tree have been measured and given a frame". But I still see some crash reports with the same problem. I can't find any documentation for this — there's questions like moveCamera with CameraUpdateFactory.newLatLngBounds crashes but they pre-date the getMapAsync
API, so they're not much help.