My getMap() method is returning null. Why is this method returning null? I looked on the Android Developers documentation to make sure I'm using this method correctly. Here a the line of code that I'm using to get the map:
mMap = ((MapFragment) getFragmentManager().findFragmentById(R.id.myMapView)).getMap();
Here is my Java code:
private ProjectionProxy proxy = new ProjectionProxy();
private GoogleMap mMap;
@Override
protected void onCreate(Bundle load) {
super.onCreate(load);
setContentView(R.layout.fragment_ride_tracking);
mMap = ((MapFragment) getFragmentManager().findFragmentById(R.id.myMapView)).getMap();
Log.e("RideTracking", "Google Map VALUE:"+mMap);
if (mMap != null) {
proxy.setProjection(mMap.getProjection());
}
Here is my XML code for that particular piece of code:
<fragment
android:id="@+id/myMapView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:name="com.google.android.gms.maps.MapFragment"/>
Here is the logcat output:
05-09 12:49:34.282: W/GooglePlayServicesUtil(5928): Google Play services out of date. Requires 3027100 but found 2012110
05-09 12:49:34.282: E/RideTracking(5928): Google Map VALUE:null
05-09 12:49:34.302: E/OGT.GPSLoggerServiceManager(5928): No GPSLoggerRemote service connected to this manager
05-09 12:49:34.322: W/dalvikvm(5928): Unable to resolve superclass of Lcom/android/gpstracker/viewer/FixedMyLocationOverlay; (2174)
05-09 12:49:34.322: W/dalvikvm(5928): Link of class 'Lcom/android/gpstracker/viewer/FixedMyLocationOverlay;' failed
05-09 12:49:34.322: W/dalvikvm(5928): Unable to resolve superclass of Lcom/android/gpstracker/viewer/FixedMyLocationOverlay; (2174)
Any help would be greatly appreciated!
Apparently the line
tells us why the map isn't instantiated.
You need to have a current version of Google Play services on your device or else you get this:
and
getMap()
will returnnull
.Try Changing it like that
If you are running it in Emulator you need to install two apk files (Read this Post)
If you have tweaked the Emulator and installed the two files already then you have to change the Google_Play_services_lib to version 4 (download it here)
Just replace the new Google_Play_services_lib with the old version#4 in eclipse and reference this to the project.