我知道这已经被多次询问和回答了,但是尽管在这里有很多解决方案,我仍然无法解决这个错误:
Failed to load map. Could not contact Google servers
我已经设置了“Google Maps Android API v2”并删除了然后重新生成了debug.keystore,然后尝试使用新密钥,但没有进一步转发。
我缺少什么想法?
我的activity_main.xml
:
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:map="http://schemas.android.com/apk/res-auto"
android:id="@+id/the_map"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:name="com.google.android.gms.maps.SupportMapFragment"
map:cameraTilt="45"
map:cameraZoom="14"
/>
清单:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.abelsoul.androidmapproject"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="11"
android:targetSdkVersion="17" />
<permission
android:name="com.abelsoul.androidmapproject.permission.MAPS_RECEIVE"
android:protectionLevel="signature" />
<uses-permission android:name="com.abelsoul.androidmapproject.permission.MAPS_RECEIVE"/>
<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" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<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" >
<activity
android:name="com.abelsoul.androidmapproject.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>
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="xxxxxxxxxxxxxxxxxxxxxx" />
</application>
</manifest>
MainActivity:
package com.abelsoul.androidmapproject;
import android.os.Bundle;
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;
}
答案 0 :(得分:2)
如果您使用WIFI而不是3G数据计划,可能需要添加访问wifi状态的权限,例如
< uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
进入您的清单文件。这条线修复了我的问题。