[英]Google Maps for Android. Failed to load map. Could not contact Google servers
I'm trying to work with Google Maps on my Android but where it should appear the map is white and I get the error: Failed to load map. 我正在尝试在Android上使用Google Maps,但是应该显示为白色的位置却出现错误:无法加载地图。 Error contacting google servers.
与Google服务器联系时出错。 I've followed many tutorials and all the answers related on that problem but I still can't fix it.
我已经阅读了许多教程和有关该问题的所有答案,但仍然无法解决。 I think I have the correct API key (Google Maps for Android) and permissions, but perhaps I forget something and somebody could help me.
我认为我拥有正确的API密钥(适用于Android的Google Maps)和权限,但也许我忘记了一些东西,有人可以帮助我。 My Android version is 4.1.1.
我的Android版本是4.1.1。 Thanks a lot.
非常感谢。
The AndroidManifest.xml: AndroidManifest.xml:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.mapmap"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="11"
android:targetSdkVersion="17"/>
<uses-feature
android:glEsVersion="0x00020000"
android:required="true"/>
<permission
android:name="com.example.mapmap.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"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="com.android.vending.CHECK_LICENSE" />
<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="KEY_FROM_GOOGLE_CONSOLE"/>
<activity
android:name="com.example.mapmap.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>
The activity_main.xml: activity_main.xml:
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:name="com.google.android.gms.maps.MapFragment"/>
The MainActivity.java: MainActivity.java:
package com.example.mapmap;
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
}
Try using 尝试使用
com.google.android.gms.maps.SupportMapFragment
instead of 代替
com.google.android.gms.maps.MapFragment
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.