无法加载地图。错误与Android谷歌地图API V2接触谷歌的服务器问题 [英] Failed to load map. Error contacting Google servers issue with android google maps api v2

查看:269
本文介绍了无法加载地图。错误与Android谷歌地图API V2接触谷歌的服务器问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在尝试使用V2 API在过去的两天里,没有成功到应用程序中的谷歌地图在我的Andr​​oid应用程序。我得到每次都是一个

I have been trying to app a Google Map in my Android app using the v2 API for the past two days, with no success. All I get every time is a

谷歌地图Android的API(16603):无法加载地图。错误接触谷歌服务器。这可能是一个问题的认证(但可能是由于网络错误)。

我跟谷歌的安装教程(<一href="https://developers.google.com/maps/documentation/android/start">https://developers.google.com/maps/documentation/android/start),试过多次在不同的工作区不同的项目,尝试了不同的谷歌帐户,通过不同的答案和建议,在这里在StackOverflow的走了,但无济于事。

I have followed Google's setup tutorial (https://developers.google.com/maps/documentation/android/start), tried multiple times with different projects in different workspaces, tried different Google accounts, gone through various answers and suggestions here in StackOverflow, but to no avail.

我使用的Eclipse 4.2.2与Android SDK工具22.01和我已经安装了谷歌Play业务(转7),另外我有进口谷歌播放services_lib 在我的工作空间,并添加一个对我的Andr​​oid项目。

I am using Eclipse 4.2.2 with Android SDK Tools 22.01 and I have installed Google Play services (rev. 7), also I have imported google-play-services_lib into my workspace and added a reference to that to my android project.

下面是我的code:

的Andr​​oidManifest.xml:

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

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

<permission
    android:name="com.example.googlemapdemo.permission.MAPS_RECEIVE"
    android:protectionLevel="signature" />
<uses-permission android:name="com.example.googlemapdemo.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.example.googlemapdemo.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="my_api_key" />
</application>

</manifest>

activity_main.xml:

<?xml version="1.0" encoding="utf-8"?>
<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"
/>

MainActivity.java

package com.example.googlemapdemo;

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;
}

}

//$c$c.google.com/apis/console:

另外,我在 HTTPS创建一个API项目/ 在那里我已经启用了谷歌地图Android的API V2 服务。然后,我用我获得的SHA1调试证书指纹

Also I created an API Project on https://code.google.com/apis/console/ where I have enabled the Google Maps Android API v2 service. Then I obtained my SHA1 debug certificate fingerprint using

keytool -list -v -keystore "C:\Users\my_user_name\.android\debug.keystore" -alias androiddebugkey -storepass android -keypass android

和输入的,并在API控制台的包名,拿到了API密钥,并把它放在清单(其中 my_api_key 是)。此过程我重复许多次,再生键,但具有相同的结果。

and entered that and the package name in the API console, got the API key and put it in the manifest (where my_api_key is). This procedure I repeated a number of times, regenerating the key but with the same result.

谁能帮助这个或暗示什么我可以尝试?任何帮助将大大AP preciated!

Could anyone help with this or suggest anything else I could try? Any help will be greatly appreciated!

推荐答案

发现它毕竟,关闭无线网络,我使用的设备后。看来,在调试的时候通过WiFi,还需要

Found it after all, after turning off WiFi on the device I was using. It seems that when debugging over WiFi you also need the

<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />

在清单中。还是不知道这只是我的情况下,它是一个普通的事情,但我想它应该是某个地方的文件中(它不是)。

in the manifest. Don't know if it was just my case or it's a general thing, but I guess it should be in the documentation somewhere (it's not).

所以,如果你正在读这篇文章,有类似的问题可以试着禁用WiFi或添加上述旁边的其他权限。

So if you are reading this and having similar problems try either disabling WiFi or adding the above permission alongside the others.

这篇关于无法加载地图。错误与Android谷歌地图API V2接触谷歌的服务器问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆