2014-02-07 58 views
0

當我運行我的應用程序有來自Eclispe的一個谷歌地圖,地圖上顯示出來,所有的地圖功能的工作..與谷歌地圖API密鑰奇怪的錯誤

但是,如果我與朋友分享我的Eclipse項目或者將我的應用導出爲APK並將其重新安裝到設備上,地圖不會顯示出來。它說:

02-07 00:26:39.644: E/Google Maps Android API(3605): Authorization failure. Please see https://developers.google.com/maps/documentation/android/start for how to correctly set up the map. 

我不知道是什麼造成這種情況。特別是因爲當我(從控制檯獲取APK並將所有內容設置爲SHA1)從Eclipse運行時,它能正常工作嗎?

這是我與地圖碎片

<android.support.v4.widget.DrawerLayout ...... > 

<LinearLayout ... > 
<RelativeLayout ..> 
<Button ... > </Button> 
<EditText .. > </EditText> 

<fragment 
android:id="@+id/map" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:layout_weight="20" 
class="com.google.android.gms.maps.SupportMapFragment" /> 
</LinearLayout> 

    <ListView android:id="@+id/left_drawer" 
android:layout_width="240dp" 
android:layout_height="match_parent" 
android:layout_gravity="start" 
android:choiceMode="singleChoice" 
android:divider="@android:color/transparent" 
android:dividerHeight="0dp" 
android:background="#111"/> 
</android.support.v4.widget.DrawerLayout> 
+0

你使用清單發佈API密鑰。 – Yugesh

+0

嗨讀完你的問題後,我想爲生成地圖鍵,你用你的android-debug-key,是嗎? –

+0

生成另一個API密鑰並嘗試。 –

回答

0

我懷疑你只有一個鍵,用於調試版本XML的main.xml。你需要另一個發行版本。

編輯:重新安裝該應用之後,因爲有一個已知的問題,只是重新上傳(通過Eclipse)或更新可能不會改變清單,其中關鍵之所在。

+0

是的,我只有一個鍵。如何添加調試密鑰? – user2998771

+0

如果您使用Eclipse,在導出已簽名的APK文件時的最後一步,您將看到SHA1密鑰。接下來,創建新密鑰,停止導出,添加新密鑰,使用新密鑰導出,然後完成。 但是,如果你不使用Eclipse,你必須通過keytool找到SHA1(我想,如果我錯了,請糾正我)。 –

0

我有simlilar發行一次,你需要去google console,然後去服務,並把谷歌地圖的Android API V2

0

有關創建生成(APK),並允許谷歌地圖可見所有設備您必須使用釋放密鑰創建密鑰庫。

入住這link