androidnullpointerexceptiongoogle-maps-android-api-2viewswitchermapfragment

Google maps v2 mapFragment inside a viewFlipper


I'm trying to create a mapFragment inside a view flipper. I have tried several approaches to it and cannot get it to work. so far I have tried:

All of these were tried in the onCreateand the call that caused them to throw a null pointer exception was inside the onResume method. I would appreciate it if anyone has experienced this behavior before and knows how to fix it.


Solution

  • As You are extending FragmentActivity, indicating that you are trying to use the Android Support package backport of fragments. However, your element refers to MapFragment, which is for the nativeAPI Level 11` edition of fragments.

    Replace MapFragment with SupportMapFragment, and that should clear up this specific crash

    if that also doesnt solve Then you have a problem with your API key or something. Check LogCat for messages