Google map view no longer loading after ADT upgrad

2020-03-28 22:42发布

问题:

I'm working on an location-aware Android app that uses Google Maps. I upgraded by ADT to 23.0.0.1245622 the other day. I think I was on v22.6.2-1085508 before then.

Now the map view only contains the Google logo and the +/- buttons. And, eerily, my logcat contains the following line:

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).

I have tried cleaning the project, by the way. No dice. I tried running this on an AVD instead of my Galaxy S3. No dice. I tried reverting to a previous revision of my code using git reset --hard. Still no dice. Perhaps most importantly, I tried creating a new API key in the console, and pasted that into my manifest. (Incidentally, I reverted to my older key after trying this experiment, if that is at all significant.)

I will post a full logcat below:

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

Here is my manifest, with my api key blotted out:

<?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>

Oh, and here's my map creation code, as well:

  @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?
  }

Note: Somewhere in this process, I also switched from a 32-bit JDK to a 64-bit one. I doubt that's relevant at all, but I just like to cover my bases.

回答1:

While looking over user2103379's answer and checking my API key, I found that the package name and the API key were correct. However, the SHA-1 for my new debug key was not added to the list of accepted clients. Oops! Anyway, I put the new SHA-1 in there, cleaned the Eclipse project (after disabling automatic post-clean build) and built the project anew. Worked fine.



回答2:

The Issue is probably happening because the Map is not loaded and the app is trying to locate you in an unloaded Map. The Map is not loading with your api key or package name. I think your api key has got changed . Please check your api key and package name.