java - ADT 升级后,Google map View 不再加载;明显的身份验证问题?

标签 java android adt google-maps-android-api-2 google-play-services

我正在开发一款使用 Google map 的位置感知 Android 应用。前几天我通过ADT升级到23.0.0.1245622。我想在那之前我使用的是 v22.6.2-1085508。

现在 map View 仅包含 Google Logo 和 +/- 按钮。而且,奇怪的是,我的 logcat 包含以下行:

07-01 12:15:08.548: E/Google Maps Android API(6299): Failed to load map. Error contacting Google servers. This is probably an authentication issue (but could be due to network errors).

顺便说一句,我已经尝试清理该项目。没有骰子。我尝试在 AVD 而不是 Galaxy S3 上运行此程序。没有骰子。我尝试使用 git reset --hard 恢复到代码的先前版本。还是没有骰子。也许最重要的是,我尝试在控制台中创建一个新的 API key ,并将其粘贴到我的 list 中。 (顺便说一句,在尝试此实验后,我恢复了旧 key ,如果这很重要的话。)

我将在下面发布完整的 logcat:

07-01 12:14:51.920: D/ActivityThread(6299): handleBindApplication:com.gregeveritt.hoodies
07-01 12:14:51.920: D/ActivityThread(6299): setTargetHeapUtilization:0.75
07-01 12:14:51.920: D/ActivityThread(6299): setTargetHeapMinFree:524288
07-01 12:14:52.560: I/Google Maps Android API(6299): Google Play services client version: 4132500
07-01 12:14:52.560: I/dalvikvm(6299): Could not find method guj.a, referenced from method gqi.a
07-01 12:14:52.560: W/dalvikvm(6299): VFY: unable to resolve static method 24932: Lguj;.a (Landroid/content/Context;)Lgri;
07-01 12:14:52.560: D/dalvikvm(6299): VFY: replacing opcode 0x71 at 0x0003
07-01 12:14:52.570: E/dalvikvm(6299): Could not find class 'gpr', referenced from method gps.a
07-01 12:14:52.570: W/dalvikvm(6299): VFY: unable to resolve new-instance 4089 (Lgpr;) in Lgps;
07-01 12:14:52.570: D/dalvikvm(6299): VFY: replacing opcode 0x22 at 0x0000
07-01 12:14:52.570: E/dalvikvm(6299): Could not find class 'gpr', referenced from method gps.a
07-01 12:14:52.570: W/dalvikvm(6299): VFY: unable to resolve new-instance 4089 (Lgpr;) in Lgps;
07-01 12:14:52.570: D/dalvikvm(6299): VFY: replacing opcode 0x22 at 0x0000
07-01 12:14:52.570: E/dalvikvm(6299): Could not find class 'gpr', referenced from method gps.a
07-01 12:14:52.570: W/dalvikvm(6299): VFY: unable to resolve new-instance 4089 (Lgpr;) in Lgps;
07-01 12:14:52.570: D/dalvikvm(6299): VFY: replacing opcode 0x22 at 0x0000
07-01 12:14:52.570: D/dalvikvm(6299): DexOpt: unable to opt direct call 0x5e9f at 0x0a in Lgps;.a
07-01 12:14:52.570: D/dalvikvm(6299): DexOpt: unable to opt direct call 0x5e9f at 0x0c in Lgps;.a
07-01 12:14:52.570: D/dalvikvm(6299): DexOpt: unable to opt direct call 0x5e9f at 0x0a in Lgps;.a
07-01 12:14:52.601: I/Google Maps Android API(6299): Google Play services package version: 5082036
07-01 12:14:52.611: W/dalvikvm(6299): VFY: unable to resolve static field 20868 (t) in Lyp;
07-01 12:14:52.611: D/dalvikvm(6299): VFY: replacing opcode 0x62 at 0x000e
07-01 12:14:52.611: W/dalvikvm(6299): VFY: unable to resolve static field 20868 (t) in Lyp;
07-01 12:14:52.611: D/dalvikvm(6299): VFY: replacing opcode 0x62 at 0x000d
07-01 12:14:52.931: W/ActivityThread(6299): ClassLoader.loadClass: The class loader returned by Thread.getContextClassLoader() may fail for processes that host multiple applications. You should explicitly specify a context class loader. For example: Thread.setContextClassLoader(getClass().getClassLoader());
07-01 12:14:52.971: I/dalvikvm(6299): Failed resolving Lcom/google/android/gms/location/internal/ParcelableGeofence; interface 4022 'Lgln;'
07-01 12:14:52.971: W/dalvikvm(6299): Link of class 'Lcom/google/android/gms/location/internal/ParcelableGeofence;' failed
07-01 12:14:52.971: E/dalvikvm(6299): Could not find class 'com.google.android.gms.location.internal.ParcelableGeofence', referenced from method glt.a
07-01 12:14:52.971: W/dalvikvm(6299): VFY: unable to resolve check-cast 2086 (Lcom/google/android/gms/location/internal/ParcelableGeofence;) in Lglt;
07-01 12:14:52.971: D/dalvikvm(6299): VFY: replacing opcode 0x1f at 0x0019
07-01 12:14:53.111: I/Adreno200-EGL(6299): <qeglDrvAPI_eglInitialize:265>: EGL 1.4 QUALCOMM build: AU_LINUX_ANDROID_JB_2.5.5.04.02.02.092.059_msm8960_JB_2.5.5_CL3896081_release_AU (CL3896081)
07-01 12:14:53.111: I/Adreno200-EGL(6299): Build Date: 06/25/13 Tue
07-01 12:14:53.111: I/Adreno200-EGL(6299): Local Branch: 
07-01 12:14:53.111: I/Adreno200-EGL(6299): Remote Branch: quic/jb_2.5.5
07-01 12:14:53.111: I/Adreno200-EGL(6299): Local Patches: NONE
07-01 12:14:53.111: I/Adreno200-EGL(6299): Reconstruct Branch: AU_LINUX_ANDROID_JB_2.5.5.04.02.02.092.059 +  NOTHING
07-01 12:14:53.161: D/OpenGLRenderer(6299): Enabling debug mode 0
07-01 12:14:53.311: I/Google Maps Android API(6299): Failed to contact Google servers. Another attempt will be made when connectivity is established.
07-01 12:14:54.022: I/Choreographer(6299): Skipped 51 frames!  The application may be doing too much work on its main thread.
07-01 12:14:54.723: I/Google Maps Android API(6299): Google Play services package version: 5082036
07-01 12:14:55.964: I/Choreographer(6299): Skipped 61 frames!  The application may be doing too much work on its main thread.
07-01 12:14:56.304: I/Timeline(6299): Timeline: Activity_idle id: android.os.BinderProxy@41bc4ef8 time:302027791
07-01 12:14:56.304: I/Timeline(6299): Timeline: Activity_idle id: android.os.BinderProxy@41bc4ef8 time:302027791
07-01 12:15:08.548: E/Google Maps Android API(6299): Failed to load map. Error contacting Google servers. This is probably an authentication issue (but could be due to network errors).
07-01 12:15:58.571: W/IInputConnectionWrapper(6299): getExtractedText on inactive InputConnection
07-01 12:15:58.571: W/IInputConnectionWrapper(6299): getTextBeforeCursor on inactive InputConnection
07-01 12:15:58.581: W/IInputConnectionWrapper(6299): getSelectedText on inactive InputConnection
07-01 12:15:58.581: W/IInputConnectionWrapper(6299): getTextAfterCursor on inactive InputConnection
07-01 12:16:04.027: I/Google Maps Android API(6299): Google Play services package version: 5082036
07-01 12:16:04.167: W/IInputConnectionWrapper(6299): getExtractedText on inactive InputConnection
07-01 12:16:04.227: W/IInputConnectionWrapper(6299): getTextBeforeCursor on inactive InputConnection
07-01 12:16:05.468: W/IInputConnectionWrapper(6299): getSelectedText on inactive InputConnection
07-01 12:16:05.498: W/IInputConnectionWrapper(6299): getTextAfterCursor on inactive InputConnection
07-01 12:16:05.518: I/Timeline(6299): Timeline: Activity_idle id: android.os.BinderProxy@41bc4ef8 time:302097011
07-01 12:16:51.027: I/Timeline(6299): Timeline: Activity_idle id: android.os.BinderProxy@41bc4ef8 time:302142518
07-01 12:17:31.530: I/Google Maps Android API(6299): Google Play services package version: 5082036
07-01 12:17:32.521: I/Choreographer(6299): Skipped 49 frames!  The application may be doing too much work on its main thread.
07-01 12:17:33.142: I/Timeline(6299): Timeline: Activity_idle id: android.os.BinderProxy@41bc4ef8 time:302184634

这是我的 list ,我的 api key 被涂掉了:

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

    <uses-sdk
        android:minSdkVersion="12"
        android:targetSdkVersion="19" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
    <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="android.permission.ACCESS_COARSE_LOCATION"/>
    <uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/>
    <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" >
    <meta-data android:name="com.google.android.gms.version"
           android:value="@integer/google_play_services_version" />
        <activity
            android:name="com.gregeveritt.hoodies.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>

哦,这也是我的 map 创建代码:

  @Override
  public void onConnected(Bundle dataBundle) {
    Toast.makeText(this, "Connected", Toast.LENGTH_SHORT).show();

    try {
      showNeighborhood();
    } catch (IOException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }

        // TODO potentially switch to SupportMapFragment, lower MinSDK from 12 to 11
        mMap = ( (MapFragment) getFragmentManager().findFragmentById(R.id.map)).getMap();
        CameraUpdate startingCamera = CameraUpdateFactory.newLatLng( new LatLng(mCurrentLocation.getLatitude(), mCurrentLocation.getLongitude()) );
        mMap.moveCamera(startingCamera);
        // TODO What if mMap was null-checked?
  }

注意:在此过程中的某个地方,我还从 32 位 JDK 切换到了 64 位 JDK。我怀疑这根本无关紧要,但我只是想掩盖我的基础。

最佳答案

在查看 user2103379 的答案并检查我的 API key 时,我发现包名称和 API key 是正确的。但是,我的新调试 key 的 SHA-1 未添加到接受的客户端列表中。哎呀!不管怎样,我把新的 SHA-1 放在那里,清理了 Eclipse 项目(在禁用自动清理后构建之后)并重新构建了项目。工作得很好。

关于java - ADT 升级后,Google map View 不再加载;明显的身份验证问题?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24515424/

相关文章:

android - ADT 提示安装支持库

java - 安卓 : How to remove white spaces in Chinese characters?

java - Android如何在对话框上制作确定按钮而不是全部大写

android - ListView的回收是如何工作的

android - 与 adb 的连接已关闭,并且发生了严重错误。 - Ubuntu 12.04

c - 按值返回与按引用返回时有哪些注意事项 - Set ADT C

java - Java中特殊链表方法的实现

java - 使用 Java 将 PDF 转换为图像

java - Minecraft ScheduleSyncRepeatingTask Bukkit 到另一个类

android - 如何使用 Android 应用程序中的 "Azure IoT Hub Device Provisioning Service"注册设备并将遥测读数发送到 Azure IoT 中心?