实现mapsv2android

实现mapsv2android,android,maps,Android,Maps,伙计们,我正在尝试实现新版谷歌地图,我已经完成了用谷歌编写的步骤,但在尝试用手机运行地图时仍然有错误 以下是我的java代码: package com.example.e_order; import android.os.Bundle; import android.support.v4.app.FragmentActivity; import android.view.Menu; public class Order_map extends FragmentActivity {

伙计们,我正在尝试实现新版谷歌地图,我已经完成了用谷歌编写的步骤,但在尝试用手机运行地图时仍然有错误

以下是我的java代码:

package com.example.e_order;

import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.view.Menu;

public class Order_map extends FragmentActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_order_map);
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.activity_order_map, menu);
        return true;
    }

}
下面是我的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"
    tools:context=".MainActivity" >

    <fragment xmlns:android="http://schemas.android.com/apk/res/android"
          android:id="@+id/map"
          android:layout_width="match_parent"
          android:layout_height="match_parent"
    />
</RelativeLayout>
sry 4长期探索。:)

新错误:

04-08 22:25:47.108: E/AndroidRuntime(19754): FATAL EXCEPTION: main 04-08 22:25:47.108: E/AndroidRuntime(19754): java.lang.NoClassDefFoundError: com.google.android.gms.R$styleable 04-08 22:25:47.108: E/AndroidRuntime(19754): at com.google.android.gms.maps.GoogleMapOptions.createFromAttributes(Unknown Source) 04-08 22:25:47.108: E/AndroidRuntime(19754): at com.google.android.gms.maps.SupportMapFragment.onInflate(Unknown Source)

您没有指定片段的类名

你应该这样做:

<fragment android:name="com.google.android.gms.maps.MapFragment"
          android:id="@+id/map_fragment"
          android:layout_width="math_parent"
          android:layout_height="match_parent" />


顺便说一句,类名不应包含下划线

您没有指定片段的类名

你应该这样做:

<fragment android:name="com.google.android.gms.maps.MapFragment"
          android:id="@+id/map_fragment"
          android:layout_width="math_parent"
          android:layout_height="match_parent" />


顺便说一句,类名不应包含下划线您应该指定
Framgnet
name
属性,并且由于您正在开发支持
SDK<11
的应用程序,因此您应该使用
SupportMapFragment
对象:

android:name="com.google.android.gms.maps.SupportMapFragment"

您应该指定
Framgnet
name
属性,并且由于您正在开发支持
SDK<11
的应用程序,因此您应该使用
SupportMapFragment
对象:

android:name="com.google.android.gms.maps.SupportMapFragment"

乍一看我错过了你看到的。。。所以+1对你也是:)04-08 22:25:47.108:E/AndroidRuntime(19754):致命异常:main 04-08 22:25:47.108:E/AndroidRuntime(19754):java.lang.NoClassDefFoundError:com.google.android.gms.R$styleable 04-08 22:25:47.108:E/AndroidRuntime(19754):在com.google.android.gms.mappoptions.createFromAttributes(未知源)04-08 22:25:47.108:E/AndroidRuntime(19754):在com.google.android.gms.maps.SupportMapFragment.onInflate(未知来源)sry评论不完整。。。我已经做了这些步骤,但它在日志中给了我一个新的错误:(乍一看我没有看到你看到的东西…你也看到了+1:)04-08 22:25:47.108:E/AndroidRuntime(19754):致命的例外:main 04-08 22:25:47.108:E/AndroidRuntime(19754):java.lang.NoClassDefFoundError:com.google.android.gms.R$styleable 04-08 22:25:47.108:E/andrountime(19754):在com.google.android.gms.maps.GoogleMapOptions.createFromAttributes(未知源)04-08 22:25:47.108:E/AndroidRuntime(19754):在com.google.android.gms.maps.SupportMapFragment.onInflate(未知源)sry,注释不完整…我已经完成了这些步骤,但它在日志中给了我一个新的错误:(顺便说一句,您是否已将google play服务作为库添加到您的项目中,如下图所示)。是的,我是这样添加的。顺便说一句,您是否已将google play服务作为库添加到您的项目中,如下图所示。是的,我是这样添加的