无法在android google maps中启动activity componentinfo java.lang.nullpointerexception?

无法在android google maps中启动activity componentinfo java.lang.nullpointerexception?,android,google-maps,Android,Google Maps,我试图通过检测用户的当前位置在android应用程序中获取最近地点列表,我根据列表视图中的谷歌类型成功获取了用户最近地点。如果我单击按钮,则我有一个按钮称为“在地图上显示地点”,它显示了衰减错误 java.lang.RuntimeException: Unable to start activity ComponentInfo{com.nws.parkd/com.nws.parkd.map.PlacesMapActivity}: java.lang.NullPointerException 这

我试图通过检测用户的当前位置在android应用程序中获取最近地点列表,我根据列表视图中的谷歌类型成功获取了用户最近地点。如果我单击按钮,则我有一个按钮称为“在地图上显示地点”,它显示了衰减错误

java.lang.RuntimeException: Unable to start activity ComponentInfo{com.nws.parkd/com.nws.parkd.map.PlacesMapActivity}: java.lang.NullPointerException
这是我的密码

map\u places.xml

<?xml version="1.0" encoding="utf-8"?>
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/mapView"
android:layout_width="match_parent"
android:layout_height="match_parent"
class="com.google.android.gms.maps.SupportMapFragment" />    
public class PlacesMapActivity extends FragmentActivity {
// Nearest places
PlacesList nearPlaces;

// Map view
// MapView mapView;
private GoogleMap mapView;

// Map overlay items
List<Overlay> mapOverlays;

AddItemizedOverlay itemizedOverlay;

GeoPoint geoPoint;
// Map controllers
MapController mc;

double latitude;
double longitude;
OverlayItem overlayitem;

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.map_places);
    MapFragment map = ((MapFragment) getFragmentManager().findFragmentById(
            R.id.mapView));
    mapView = map.getMap();

    // Getting intent data
    Intent i = getIntent();

    // Users current geo location
    String user_latitude = i.getStringExtra("user_latitude");
    String user_longitude = i.getStringExtra("user_longitude");

    // Nearplaces list
    nearPlaces = (PlacesList) i.getSerializableExtra("near_places");

    // mapView = (MapView) findViewById(R.id.mapView);
    // mapView.setBuiltInZoomControls(true);

    // mapOverlays = mapView.getOverlays();

    // Geopoint to place on map
    geoPoint = new GeoPoint(
            (int) (Double.parseDouble(user_latitude) * 1E6),
            (int) (Double.parseDouble(user_longitude) * 1E6));

    // Drawable marker icon
    Drawable drawable_user = this.getResources().getDrawable(
            R.drawable.mark_red);

    itemizedOverlay = new AddItemizedOverlay(drawable_user, this);

    // Map overlay item
    overlayitem = new OverlayItem(geoPoint, "Your Location", "That is you!");

    itemizedOverlay.addOverlay(overlayitem);

    mapOverlays.add(itemizedOverlay);
    itemizedOverlay.populateNow();

    // Drawable marker icon
    Drawable drawable = this.getResources().getDrawable(
            R.drawable.mark_blue);

    itemizedOverlay = new AddItemizedOverlay(drawable, this);

    // mc = mapView.getController();

    // These values are used to get map boundary area
    // The area where you can see all the markers on screen
    int minLat = Integer.MAX_VALUE;
    int minLong = Integer.MAX_VALUE;
    int maxLat = Integer.MIN_VALUE;
    int maxLong = Integer.MIN_VALUE;

    // check for null in case it is null
    if (nearPlaces.results != null) {
        // loop through all the places
        for (Place place : nearPlaces.results) {
            latitude = place.geometry.location.lat; // latitude
            longitude = place.geometry.location.lng; // longitude

            // Geopoint to place on map
            geoPoint = new GeoPoint((int) (latitude * 1E6),
                    (int) (longitude * 1E6));

            // Map overlay item
            overlayitem = new OverlayItem(geoPoint, place.name,
                    place.vicinity);

            itemizedOverlay.addOverlay(overlayitem);

            // calculating map boundary area
            minLat = (int) Math.min(geoPoint.getLatitudeE6(), minLat);
            minLong = (int) Math.min(geoPoint.getLongitudeE6(), minLong);
            maxLat = (int) Math.max(geoPoint.getLatitudeE6(), maxLat);
            maxLong = (int) Math.max(geoPoint.getLongitudeE6(), maxLong);
        }
        mapOverlays.add(itemizedOverlay);

        // showing all overlay items
        itemizedOverlay.populateNow();
    }

    // Adjusting the zoom level so that you can see all the markers on map
    // mapView.getController().zoomToSpan(Math.abs(minLat - maxLat),
    // Math.abs(minLong - maxLong));

    // Showing the center of the map
    mc.animateTo(new GeoPoint((maxLat + minLat) / 2,
            (maxLong + minLong) / 2));
    // mapView.postInvalidate();

}

private void setUpMapIfNeeded() {
    // Do a null check to confirm that we have not already instantiated the
    // map.
    if (mapView == null) {
        mapView = ((MapFragment) getFragmentManager().findFragmentById(
                R.id.mapView)).getMap();
        // Check if we were successful in obtaining the map.
        if (mapView != null) {
            // The Map is verified. It is now safe to manipulate the map.

        }
    }
}

}

请检查您的清单文件。您是否添加了所有必要的活动?

是否添加了所有必要的活动

mapOverlays = new List<Overlay>() ;

before mapOverlays.add()
mapOverlays=新列表();
在mapOverlays.add()之前
您尚未创建mapOverlays的对象,因此它为空


您正在尝试执行mapOverlays.add(),因此出现了异常

第55行PlacesMapActivity.java是什么?哪一行是PlacesMapActivity.java:55?@raghundandan第55行是Intent i=getIntent();谢谢你的快速回复reply@abhisheksingh第55行是Intent i=getIntent();谢谢你的快速回复reply@Nareshkumarkondapalli您应该使用
SupportMapFragment
SupportMapFragment fm=(SupportMapFragment)getSupportFragmentManager().findFragmentById(R.id.mapview);mapView=fm.getMap()在这种情况下,您将获得“未找到活动”异常。op正在获取NPE时。@Lia Pronina我在清单文件中添加了google地图的所有活动和所有权限,我正在尝试添加mapOverlays=new List();但它是说不能实例化类型ListOverlay是您定义的一个类吗?
mapOverlays = new List<Overlay>() ;

before mapOverlays.add()