Android Maps v 2

时间:2013-01-31 03:54:06

标签: android google-maps-android-api-2

我正在尝试将Android Maps版本2集成到我的应用中。 我已经开始使用此链接提供的示例

https://developers.google.com/maps/documentation/android/intro#sample_code

我收到授权失败例外。

下面的文字来自logcat

01-30 22:51:25.953: D/GestureDetector(5418): Change mBiggerTouchSlopSquare from 400 to 729
01-30 22:51:26.003: D/dalvikvm(5418): GC_CONCURRENT freed 793K, 19% free 3832K/4707K, paused 2ms+2ms
01-30 22:51:26.023: I/global(5418): call createSocket() return a new socket.
01-30 22:51:26.063: D/libEGL(5418): loaded /system/lib/egl/libGLES_android.so
01-30 22:51:26.083: D/libEGL(5418): loaded /system/lib/egl/libEGL_adreno200.so
01-30 22:51:26.083: D/libEGL(5418): loaded /system/lib/egl/libGLESv1_CM_adreno200.so
01-30 22:51:26.083: D/libEGL(5418): loaded /system/lib/egl/libGLESv2_adreno200.so
01-30 22:51:26.103: I/Adreno200-EGLSUB(5418): <ConfigWindowMatch:2087>: Format RGBA_8888.
01-30 22:51:26.123: D/memalloc(5418): ion: Mapped buffer base:0x53a22000 size:3768320 offset:0 fd:93
01-30 22:51:26.143: D/OpenGLRenderer(5418): Enabling debug mode 0
01-30 22:51:26.173: I/Adreno200-EGLSUB(5418): <ConfigWindowMatch:2098>: Format RGBX_8888.
01-30 22:51:26.203: D/memalloc(5418): ion: Mapped buffer base:0x543d7000 size:3391488 offset:0 fd:97
01-30 22:51:26.243: D/memalloc(5418): ion: Mapped buffer base:0x54c96000 size:3768320 offset:0 fd:100
01-30 22:51:26.293: D/memalloc(5418): ion: Mapped buffer base:0x55156000 size:3768320 offset:0 fd:103
01-30 22:51:26.323: D/dalvikvm(5418): GC_FOR_ALLOC freed 1359K, 31% free 4020K/5795K, paused 17ms
****01-30 22:51:26.333: E/Google Maps Android API(5418): Authorization failure.****
01-30 22:51:26.373: D/memalloc(5418): ion: Mapped buffer base:0x55560000 size:3391488 offset:0 fd:106
01-30 22:51:26.393: D/memalloc(5418): ion: Mapped buffer base:0x558ac000 size:3391488 offset:0 fd:109

有人可以向我提供有关如何解决此问题的信息吗? 如果这是一个微不足道的问题,我很抱歉,我是Android应用程序开发的新手。

Android清单文件

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

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

    <uses-sdk
        android:minSdkVersion="8"
        android:targetSdkVersion="16" />
    <uses-permission android:name="android.permission.INTERNET"/>
<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"/>

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name="com.googlemapsdemo.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>
     <permission
          android:name="com.googlemapsdemo.permission.MAPS_RECEIVE"
          android:protectionLevel="signature"/>
        <uses-permission android:name="com.googlemapsdemo.permission.MAPS_RECEIVE"/>

</manifest>

4 个答案:

答案 0 :(得分:0)

这表示您的清单中没有有效的Maps V2 API密钥,或者API密钥未配置正确的APK签名密钥指纹或Android应用程序包名称。 the documentation中包含获取API密钥。

答案 1 :(得分:0)

创建API密钥。将它放在您的清单文件中 -

<meta-data android:name="com.google.android.maps.v2.API_KEY" android:value="YOUR_API_KEY_HERE" />


请阅读链接中的获取API密钥部分 - https://developers.google.com/maps/documentation/android/start#getting_the_google_maps_android_api_v2

答案 2 :(得分:0)

您必须按照以下步骤获取地图:

1.您应该在API key将目录更改为Command prompt并使用此命令Bin folder of your Jdk使用此命令获得keytool -v -list -keystore C:\Users\Ponmani\.android\debug.keystore。通过使用此命令,您将获得MD5 fingerprint

2.使用此MD5 fingerprint。你必须signup for getting API key

3.确保您使用的是Google API's设备

4.在Manifest file设置"INTERNET"GOOGLE MAPS的权限。如果你正确地遵循这些意味着确定地图将起作用。

答案 3 :(得分:0)

我使用过此处提供的清单文件 link!它工作了