Google maps 谷歌地图膨胀异常:二进制xml文件错误

Google maps 谷歌地图膨胀异常:二进制xml文件错误,google-maps,android-fragments,binary,Google Maps,Android Fragments,Binary,我一直在玩在地图上添加标记的游戏。目前,我有一个谷歌地图引用另一个活动,我正试图从当前活动访问相同的地图&我正在处理它。然而,我得到了一个错误 com.example.googlemapsV2 import com.google.android.gms.maps.CameraUpdateFactory; import com.google.android.gms.maps.GoogleMap; import com.google.android.gms.maps.MapFragment; imp

我一直在玩在地图上添加标记的游戏。目前,我有一个谷歌地图引用另一个活动,我正试图从当前活动访问相同的地图&我正在处理它。然而,我得到了一个错误

com.example.googlemapsV2

import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.MapFragment;
import com.google.android.gms.maps.GoogleMap.OnMapClickListener;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.MarkerOptions;

import android.annotation.SuppressLint;
import android.annotation.TargetApi;
import android.app.Activity;
import android.os.Build;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;

/**
 * Adds a marker to the map with co-ordinates shown
 * 
 * @author Aaron
 * 
 */

@TargetApi(Build.VERSION_CODES.HONEYCOMB)
public class mapAddingMarker extends FragmentActivity {

    private GoogleMap map;

    @SuppressLint("NewApi")
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main); 
System.out.print("hello this works");
//       get map from base class
        currentLocation x = new currentLocation();
        x.onCreate(savedInstanceState);
        map = x.getMap(); // get the map reference

//map = ((MapFragment) getFragmentManager()
//      .findFragmentById(R.id.map)).getMap();
//addingMarkerToMap();
    }

    /**
     * Adds a marker to the current map with co-ordinates of location
     */

    public void addingMarkerToMap() {
        // make map clickable
                map.setOnMapClickListener(new OnMapClickListener() {//janmarstame

                    @Override
                    public void onMapClick(LatLng point) {

                        // creating marker options
                        MarkerOptions markerOp = new MarkerOptions();
                        // set position of marker at that point
                        markerOp.position(point);
                        // setting the title for the marker
                        markerOp.title(point.latitude + " : " + point.longitude);

                        // clear the previously touched position
                        map.clear();

                        // Animates the movement of the camera from the current position
                        // to the position defined in the update.
                        map.animateCamera(CameraUpdateFactory.newLatLng(point));
                        //place the marker on the map
                        map.addMarker(markerOp);

                    }

                });

    }

}
我的布局:xml文件

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context=".MainActivity" >

       <TextView
        android:id="@+id/tv_location"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" />

       <fragment
          android:id="@+id/map"
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          android:name="com.google.android.gms.maps.MapFragment"
          android:enabled = "true"
          android:clickable = "true"/>

</RelativeLayout>

看起来您没有从导入项目

\extras\google\google_play_services\libproject\google-play-services_lib.
将其作为库添加到当前项目中

请确保已在11下为API使用SupportMapFragment

?xml version="1.0" encoding="utf-8"?>
  <fragment xmlns:android="http://schemas.android.com/apk/res/android"
  android:id="@+id/map"
   android:name="com.google.android.gms.maps.SupportMapFragment"
   android:layout_width="wrap_content"
   android:layout_height="match_parent" />
?xml version=“1.0”encoding=“utf-8”>

如果这解决了您的问题,请访问
?xml version="1.0" encoding="utf-8"?>
  <fragment xmlns:android="http://schemas.android.com/apk/res/android"
  android:id="@+id/map"
   android:name="com.google.android.gms.maps.SupportMapFragment"
   android:layout_width="wrap_content"
   android:layout_height="match_parent" />