I am trying to build an application using Google Maps API v2 but the thing is, the application keeps giving me force closes although i followed all the required instructions. >
I found you missed several things in your code.
Answer 1: Your GPSonMAP.java must be modified like below;
public class GPSonMap extends android.support.v4.app.FragmentActivity{
GoogleMap googlemap; // "MapView map;" is wrong
//MapController controller; ==> it was depreciated.
LocationManager locationManager;
LocationListener listener;
PendingIntent pendingIntent ;
Criteria criteria;
//MapOverlay overlay; ==> it was depreciated.
SupportMapFragment fm; // add this
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.map);
Log.d("", "entered");
//map = (MapView)findViewById(R.id.mapView); ==> delete it.
fm = (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.mapView);
googleMap = fm.getMap();
}
}
After modifying the above, press "Ctrl + Shft + (alphabet) O " and some required classes will be imported.
Answer 2: Your xml file in layout must be modified like below;
Your MainActivity is not MapsActivity, but GPSonMap.
Answer 3: Your Manifest file does not match your package name with the described package name in the manifest file. Please match the package name with the same one.
Modify "com.example.example" to your package name.
After copying and pasting some codes, you MUST check the package name and class name at least.