Troubleshooting tips for Maps chapter


#1

Keep in mind the following if you are having maps problems:

1_ getMap() is deprecated. You should check out the API and note that getMapAsync() is now the call to make.
Implement the callback interface OnMapReadyCallback and override onMapReady method. If you are getting a null map, that is probably why(in addition to lifecycle timing issue). The new method guarantees a non-null map.

2_ getMap or getMapAsync, should not be called in onCreateView(). It says in the docs that the map won’t be non-null until after onCreateView() has been called. Thus call it in onActivityCreated().

3_ If you are using the emulator and you see that play services are not available despite having installed and followed directions, install the GoogleAPI’s system image from the SDK Manager, SDK Version 19+. If you want the emulator to rotate in addition to displaying maps, you must use GoogleAPI’s system image v21.

4_ make sure that you are using a debug keystore SHA1 fingerprint for your API key and not release. I found that the API did not respond with a release keystore fingerprint and verified it on SO.