没有地图的模拟器上的Android googlemap

没有地图的模拟器上的Android googlemap,android,google-maps,Android,Google Maps,我已经对这个问题困惑了好几天了。 当我在emulator 4.2.2 api 17上运行它时,它显示:除非更新Google Play服务,否则该应用程序不会运行 我不知道该怎么办。我的代码如下: 清单: <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.demogoog

我已经对这个问题困惑了好几天了。 当我在emulator 4.2.2 api 17上运行它时,它显示:除非更新Google Play服务,否则该应用程序不会运行

我不知道该怎么办。我的代码如下:

清单:

 <?xml version="1.0" encoding="utf-8"?>
 <manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.demogooglemap"
android:versionCode="1"
android:versionName="1.0" >

<uses-sdk
    android:minSdkVersion="8"
    android:targetSdkVersion="17" />

<permission
    android:name="com.example.demogooglemap.permission.MAPS_RECEIVE"
    android:protectionLevel="signature" />

 <uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
<!--  The following two permissions are not required to use      Google Maps Android API v2,but     are recommended. -->
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="com.example.demogooglemap.permission.MAPS_RECEIVE" />
 <uses-feature
    android:name="android.hardware.location"
    android:required="false" />
<uses-feature
    android:name="android.hardware.location.network"
    android:required="false" />
<uses-feature android:name="android.hardware.location.gps" />
<uses-feature
    android:name="android.hardware.wifi"
    android:required="false" />

<uses-feature
    android:glEsVersion="0x00020000"
    android:required="true" />

<application
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >

     <meta-data
        android:name="com.google.android.maps.v2.API_KEY"
        android:value="AIzaSyB6ZyogESLYJrYzZJ2h0QTJyyPna8m3CCI" />
     <meta-data android:name="com.google.android.gms.version" 
         android:value="@integer/google_play_services_version" />


    <activity
        android:name="com.example.demogooglemap.MainActivity"
        android:label="@string/app_name" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
  </application>

 </manifest>
<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/header"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="@string/hello_world" />

<fragment
    android:id="@+id/map"
    android:layout_below="@+id/header"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    class="com.google.android.gms.maps.SupportMapFragment" />

</RelativeLayout>`

我还导入了google-play-services库。

您处理google-play服务的方式不正确。您应该(我会说“必须”)检查它是否符合链接库的要求,并协调一致(使用自己的代码而不是我的26354):


或者在您的设备上打开此链接:

转到SDK管理器,将Android api版本更新为19

在windows的开始按钮中搜索,键入
**SDK管理器**
您将到达那里,您将看到一些更新,安装这些更新


您有更新的google play服务吗?我从SDK管理器下载。如何更新?打开sdk管理器并更新您的google play服务我无法选择更新。你能告诉我一个细节吗?我怎么知道我自己的代码?我没有“TDApplication”谢谢,我试过了,但是它停止了,logcat显示“java.lang.NullPointerException”,我没有参数“mContext”。当然你没有,geeez!但是你有
isGooglePlayServicesAvailable()
的文档,所以你可以用正确的东西代替它。这是一个通用的示例代码,在不理解任何内容的情况下不能复制和粘贴。我正在学习android的程序。你的意思是安装安卓4.4?谷歌游戏库应该在你的工作区/工作目录中,甚至可以添加“为你添加谷歌游戏库”项目。。。
 import android.os.Bundle;
 import android.app.Activity;
 import android.support.v4.app.FragmentActivity;
 import android.view.Menu;

 public class MainActivity extends FragmentActivity {

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

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

  }
int errorCode = GooglePlayServicesUtil.isGooglePlayServicesAvailable(mContext);
if( errorCode != ConnectionResult.SUCCESS ) {
    if( GooglePlayServicesUtil.isUserRecoverableError( errorCode ) ) {
        Dialog errorDialog = GooglePlayServicesUtil.
                    getErrorDialog(errorCode, this, 26354);
        if( errorDialog != null ) {
            errorDialog.show();
        } else {
               // open GooglePlayService app page in store:
               // https://play.google.com/store/apps/details?id=com.google.android.gms
    }
}