Google Maps Android v2授权失败

时间:2012-12-07 05:19:47

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

我正在测试具有2.3.6的实际设备上的示例Google代码。我认为它可能是密钥的问题,因此我通过Google的API控制台在其他帐户上创建了不同的密钥。同样的问题“Google映射Android API授权失败“。 这是日志:

12-07 10:31:30.476: D/dalvikvm(17791): DexOpt: couldn't find field Landroid/content/res/Configuration;.smallestScreenWidthDp
12-07 10:31:30.484: W/dalvikvm(17791): VFY: unable to resolve instance field 24
12-07 10:31:30.484: D/dalvikvm(17791): VFY: replacing opcode 0x52 at 0x0012
12-07 10:31:30.484: D/dalvikvm(17791): VFY: dead code 0x0014-0018 in Lcom/google/android/gms/common/GooglePlayServicesUtil;.b (Landroid/content/res/Resources;)Z
12-07 10:31:30.718: D/dalvikvm(17791): GC_CONCURRENT freed 197K, 46% free 3063K/5639K, external 408K/517K, paused 3ms+4ms
12-07 10:31:30.789: W/dalvikvm(17791): Unable to resolve superclass of Lmaps/a/du; (411)
12-07 10:31:30.789: W/dalvikvm(17791): Link of class 'Lmaps/a/du;' failed
12-07 10:31:30.789: W/dalvikvm(17791): Unable to resolve superclass of Lmaps/a/ej; (2363)
12-07 10:31:30.789: W/dalvikvm(17791): Link of class 'Lmaps/a/ej;' failed
12-07 10:31:30.789: W/dalvikvm(17791): Unable to resolve superclass of Lmaps/j/k; (2379)
12-07 10:31:30.789: W/dalvikvm(17791): Link of class 'Lmaps/j/k;' failed
12-07 10:31:30.789: E/dalvikvm(17791): Could not find class 'maps.j.k', referenced from method maps.y.ae.a
12-07 10:31:30.789: W/dalvikvm(17791): VFY: unable to resolve new-instance 3571 (Lmaps/j/k;) in Lmaps/y/ae;
12-07 10:31:30.789: D/dalvikvm(17791): VFY: replacing opcode 0x22 at 0x007d
12-07 10:31:30.820: D/dalvikvm(17791): VFY: dead code 0x007f-008f in Lmaps/y/ae;.a (Landroid/view/LayoutInflater;Lcom/google/android/gms/maps/GoogleMapOptions;Z)Lmaps/y/ae;
12-07 10:31:31.281: D/dalvikvm(17791): GC_CONCURRENT freed 297K, 46% free 3222K/5959K, external 408K/517K, paused 3ms+4ms
12-07 10:31:31.523: D/dalvikvm(17791): GC_EXTERNAL_ALLOC freed 227K, 45% free 3397K/6087K, external 431K/517K, paused 52ms
12-07 10:31:31.648: I/System.out(17791): 0
12-07 10:31:31.734: D/dalvikvm(17791): GC_CONCURRENT freed 188K, 43% free 3531K/6151K, external 544K/1029K, paused 5ms+4ms
12-07 10:31:32.125: D/libEGL(17791): loaded /system/lib/egl/libGLES_hgl.so
12-07 10:31:32.132: D/BRCM_EGL(17791): eglCreateContext() context: 0xd7090, VC context 1, Thread 17810
12-07 10:31:32.148: D/BRCM_EGL(17791): eglCreateWindowSurface() surface: 0xd70d0, VC surface: 1, Thread: 17810
12-07 10:31:32.148: D/BRCM_EGL(17791): eglMakeCurrent(0xd7090, 0xd70d0, 0xd70d0) Thread: 17810
12-07 10:31:32.859: E/Google Maps Android API(17791): Authorization failure.

这是我的清单:

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

    <uses-sdk
        android:minSdkVersion="8"
        android:targetSdkVersion="16" />
    <uses-feature android:glEsVersion="0x00020000" android:required="true"/>
    <permission
         android:name="com.smartapps4u.googlemapslib.permission.MAPS_RECEIVE"
         android:protectionLevel="signature"/>
<uses-permission  android:name="com.smartapps4u.googlemapslib.permission.MAPS_RECEIVE"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<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-library android:name="com.google.android.maps" />
    <application
        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="My API key"/>

        <activity
            android:name=".MainActivity"
            android:label="@string/title_activity_main" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

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

    </application>

</manifest>

任何帮助都将不胜感激。

2 个答案:

答案 0 :(得分:4)

解决了它。我的错误很愚蠢。使用错误的api密钥。使用api密钥签名app。用api密钥替换调试密钥库并解决了问题。

答案 1 :(得分:0)

有同样的问题和@Sunkenglory的答案是正确的,只是在我寻找解决方案时为像我这样的新手添加一些信息。

在mac osX上,我的调试密钥库位于:

~/.android/debug.keystore

转到该文件夹​​并运行以下

keytool -list -v -keystore debug.keystore

这给了我在谷歌控制台中输入的正确sha1,现在它可以正常工作。