Managed to get the codes error free, however upon launching, I somehow always get a null pointer exception at the line mMap = mapFrag.getMap();
Why is this so? Am I missing some imports or some steps? I am unsure if it's the SupportMapFragment or GoogleMap object that's causing the problem.
package com.fragments;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.SupportMapFragment;
public class MapFragment extends SherlockMapFragment {
private GoogleMap mMap;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View root = super.onCreateView(inflater, container, savedInstanceState);
SupportMapFragment mapFrag= (SupportMapFragment)getSupportFragmentManager().findFragmentById(R.id.fragment_map);
mMap = mapFrag.getMap(); //null pointer is here
return root;
}
}
Edit: This is part of the implementation based on the solution given in this question here