GoogleMap的V2无法加载map.Error联系谷歌服务器 [英] GoogleMap V2 Failed to load map.Error contacting Google servers

查看:379
本文介绍了GoogleMap的V2无法加载map.Error联系谷歌服务器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是谷歌阿比19。我收到堆栈跟踪误差在运行时在运行谷歌地图V2。无法加载地图。错误接触谷歌服务器。这可能是一个认证问题的(但可能是由于网络错误)。

I am using a Google Api 19.I am getting the Stacktrace error at runtime while running the Google map V2. Failed to load map. Error contacting Google servers. This is probably an authentication issue (but could be due to network errors).

堆栈跟踪:

 E/Random(2450)          : > 17.384058210414967, 78.48609545247936
 E/Random(2450)          : > 17.385480575802443, 78.48634970995319
 E/Random(2450)          : > 17.384707320313552, 78.48718165182942
 E/Random(2450)          : > 17.384469518257607, 78.48737972822704
 E/Random(2450)          : > 17.386012910991372, 78.48664538492055
 E/Random(2450)          : > 17.384268963692328, 78.48682608163563
 E/Random(2450)          : > 17.385942881352822, 78.48616019819285
 E/Random(2450)          : > 17.384971626221553, 78.48736770924768
 E/Random(2450)          : > 17.384794739104553, 78.48631955135781
 E/Random(2450)          : > 17.38564903886939, 78.48614895429334
 D/gralloc_goldfish(2450): Emulator without GPU emulation detected.
 I/Choreographer(2450)   : Skipped 621 frames!  The application may be doing too much work on its main thread.
 E/Google Maps Android API(2450): Failed to load map. Error contacting Google servers. This is probably an authentication issue (but could be due to network errors).

清单:

<?xml version="1.0" encoding="utf-8"?>

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="info.androidhive.googlemapsv2"
    android:versionCode="1"
    android:versionName="1.0" >

    <permission
        android:name="info.androidhive.googlemapsv2.permission.MAPS_RECEIVE"
        android:protectionLevel="signature" />

    <uses-permission android:name="info.androidhive.googlemapsv2.permission.MAPS_RECEIVE" />

    <uses-sdk
        android:minSdkVersion="12"
        android:targetSdkVersion="19" />

    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

    <!-- Required to show current location -->
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />

    <!-- Required OpenGL ES 2.0. for Maps V2 -->
    <uses-feature
        android:glEsVersion="0x00020000"
        android:required="true" />

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

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

        <activity
            android:name="info.androidhive.googlemapsv2.MainActivity"
            android:label="@string/app_name"
            android:theme="@style/AppBaseTheme">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

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

        <!-- Goolge API Key -->
        <meta-data
            android:name="com.google.android.maps.v2.API_KEY"
            android:value="AIzaSyB2p7rsFLCuYmjA8SnRsIZfjWugwgh4wtU" />

    </application>   

</manifest>       

MainActivity.java:

package com.map.googlemap;

import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.widget.Toast;

import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.MapFragment;
import com.google.android.gms.maps.model.BitmapDescriptorFactory;
import com.google.android.gms.maps.model.CameraPosition;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.MarkerOptions;

public class MainActivity extends Activity {

    // Google Map
    private GoogleMap googleMap;

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

        try {
            // Loading map
            initilizeMap();

            // Changing map type
            googleMap.setMapType(GoogleMap.MAP_TYPE_NORMAL);


            // Showing / hiding your current location
            googleMap.setMyLocationEnabled(true);

            // Enable / Disable zooming controls
            googleMap.getUiSettings().setZoomControlsEnabled(false);

            // Enable / Disable my location button
            googleMap.getUiSettings().setMyLocationButtonEnabled(true);

            // Enable / Disable Compass icon
            googleMap.getUiSettings().setCompassEnabled(true);

            // Enable / Disable Rotate gesture
            googleMap.getUiSettings().setRotateGesturesEnabled(true);

            // Enable / Disable zooming functionality
            googleMap.getUiSettings().setZoomGesturesEnabled(true);

            double latitude = 12.987100;
            double longitude = 80.251692;

            // lets place some 10 random markers
            for (int i = 0; i <1; i++) {
                // random latitude and logitude
                double[] randomLocation = createRandLocation(latitude,
                        longitude);

                // Adding a marker
                MarkerOptions marker = new MarkerOptions().position(
                        new LatLng(randomLocation[0], randomLocation[1]))
                        .title("Hello Maps " + i);

                Log.e("Random", "> " + randomLocation[0] + ", "
                        + randomLocation[1]);

                // changing marker color
                if (i == 0)
                    marker.icon(BitmapDescriptorFactory
                            .defaultMarker(BitmapDescriptorFactory.HUE_ROSE));
                if (i == 1)
                    marker.icon(BitmapDescriptorFactory
                            .defaultMarker(BitmapDescriptorFactory.HUE_ORANGE));

                googleMap.addMarker(marker);

                // Move the camera to last position with a zoom level
                if (i == 0) {
                    CameraPosition cameraPosition = new CameraPosition.Builder()
                            .target(new LatLng(randomLocation[0],
                                    randomLocation[1])).zoom(15).build();

                    googleMap.animateCamera(CameraUpdateFactory
                            .newCameraPosition(cameraPosition));
                }
            }

        } catch (Exception e) {
            e.printStackTrace();
        }

    }

    @Override
    protected void onResume() {
        super.onResume();
        initilizeMap();
    }

    /**
     * function to load map If map is not created it will create it for you
     * */
    private void initilizeMap() {
        if (googleMap == null) {
            googleMap = ((MapFragment) getFragmentManager().findFragmentById(
                    R.id.map)).getMap();

            // check if map is created successfully or not
            if (googleMap == null) {
                Toast.makeText(getApplicationContext(),
                        "Sorry! unable to create maps", Toast.LENGTH_SHORT)
                        .show();
            }
        }
    }


    private double[] createRandLocation(double latitude, double longitude) {

        return new double[] { latitude + ((Math.random() - 0.5) / 500),
                longitude + ((Math.random() - 0.5) / 500),
                150 + ((Math.random() - 0.5) * 10) };
    }
}                 

输出:

我不知道如何解决这些堆栈跟踪Error.Anybody可以帮我these.Thank你。

I doesn't know how to solve these stackTrace Error.Anybody can help me with these.Thank You.

推荐答案

我通过执行以下步骤解决了这些问题:

I solved these problem by doing the following steps:


  • 在仿真器:

您必须使用最新的API 谷歌的API(谷歌公司) - API级别
19

You have to use the latest API Google APIs(Google Inc.)-API Level 19.

执行放置在屏幕截图本身剩下的事情。

Do the rest of the things placed in the screenshot itself.

API密钥:

创建新的API密钥并仔细查看谷歌地图API密钥和SHA密钥。

Create New API Key and Check carefully about Google Map API key and SHA Key.

谷歌播放服务:

您必须下载最新的谷歌游戏服务
    com.android.vending-4.8.20.apk 。在该网站如果谷歌播放
   服务没有工作意味着你可以找到很多的网站
   互联网名为 com.android.vending 4.8.20.apk

You have to download the latest Google Play Services com.android.vending-4.8.20.apk.In that site if google play services wasn't working means you can find a lot of sites in internet named com.android.vending 4.8.20.apk.

您可以运行谷歌通过使用命令提示符发挥服务
    ADB安装com.android.vending 4.8.20.apk

you can run the Google play Services by using the Command Prompt adb install com.android.vending 4.8.20.apk.

注意:您必须下载最新的谷歌播放服务,因为逐年最新版本将在网上更新

Note: You have to download the latest Google play services because year by year latest version will be updated in internet.

输出

这篇关于GoogleMap的V2无法加载map.Error联系谷歌服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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