2014-10-27 171 views
0

我目前正在使用Google Maps API v2的應用程序。但是MapView只顯示灰色背景,Google徽標和縮放按鈕。Google地圖只顯示灰色背景,而不顯示地圖

下面是錯誤信息:

10-27 10:50:25.309: D/REQUEST(18335): Connection opened to:https://clients4.google.com/glm/mmap/api 
10-27 10:50:25.309: D/REQUEST(18335): Open Connection 
10-27 10:50:26.239: D/REQUEST(18335): DRD(24): 62|147 
10-27 10:50:26.239: D/REQUEST(18335): Close 
10-27 10:50:26.239: D/REQUEST(18335): Error processing: [email protected] not retrying 
10-27 10:50:26.239: D/REQUEST(18335): Retrying: [email protected] 

而另:

10-27 10:49:49.309: E/REQUEST(18335): In Error Mode 
10-27 10:49:49.319: E/Google Maps Android API(18335): Failed to load map. Error contacting Google servers. This is probably an authentication issue (but could be due to network errors). 

我的清單確實包含我的API密鑰和不同的權限:

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

    <permission 
     android:name="de.hobbit.xmltest.permission.MAPS_RECEIVE" 
     android:protectionLevel="signature" /> 

    <uses-permission android:name="de.hobbit.xmltest.permission.MAPS_RECEIVE" /> 

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

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

    <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" /> 



    <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" /> 
     <meta-data 
      android:name="com.google.android.maps.v2.API_KEY" 
      android:value="SOMEKEY" /> 

     <activity 
      android:name=".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> 
     <activity 
      android:name=".SingleActivity" 
      android:label="@string/title_activity_single" > 
     </activity> 
    </application> 

</manifest> 

我希望有人能找到我的錯。

謝謝。

+2

請勿發佈API密鑰!你可以並且應該把它扔掉並生成一個新的......這就像在這裏發佈你的密碼! – WarrenFaith 2014-10-27 10:03:46

+0

順便說一下,你應該總是針對清單中的最新API級別,而不是與你的min sdk相同。 – WarrenFaith 2014-10-27 10:05:01

+1

[檢查是否有幫助](http://stackoverflow.com/questions/17491400/failed-to-load-map-error-contacting-google-servers-issue-with-android-google-ma) – 2014-10-27 10:05:37

回答

1

我使用了錯誤的密鑰庫...

而不是使用調試密鑰庫,我用我的實際密鑰庫。

要訪問調試密鑰庫中蝕

1.Go到窗口 - >首選項 - > Android->構建

2.複印的SHA1指紋

3.Generate在API密鑰開發人員控制檯使用調試密鑰庫

+0

這節省了我的一天。只想爲Android Studio用戶添加信息:您可以訪問〜/ .android/debug.keystore中的調試密鑰庫。要讀取sha1,可以使用以下命令(假設它在.android文件夾下運行):keytool -list -v -keystore debug.keystore – 2014-12-31 12:38:14