android 的mapview的apikey

來源:互聯網
上載者:User

我的第一個地圖程式是android sdk 1.0的時候寫的,那個時候剛剛apikey才出來,當時申請了,在模擬器上和手機上都能出來地圖資源,結果等我換到android sdk 1.5了,在手機上可以跑起來,在模擬器上不行,於是這個問題一直困饒著我,我在網上查過一些資料,一個最值得信任的答案是說模擬器上把地圖資源關掉了,所以我一直都認為是這樣的,當時由於本公司只有我一個做地圖相關的開發,後來在和其它公司的開發人員交流的時候發現在模擬器上可以顯示地圖資源,我就很鬱悶了,不知道是什麼原因,因為我的程式以及配置一直都沒什麼問題,怎麼地圖會出不來呢,找了好久,我懷疑是不是我的apikey到期了,結果我重新申請了一個,果然地圖出來了,最後仔細想想,確實當每個版本更新是應該重新申請一個apikey,寫在這裡供大家參考,以便不要再範同樣的錯誤了。

 

**************************************************************************

 

以下詳細寫一下如何申請apikey:

1、找到debug.keystore:

開啟Eclipse--->Windows--->Preferences--->Android--->Build
查看預設的debug keystore位置,我的是C:/Documents and Settings/Administrator/.android/debug.keystore

2、運行cmd,並輸入命令:keytool -list -alias androiddebugkey -keystore "C:/Documents and Settings/Administrator/.android/debug.keystore" -storepass android -keypass android

結果會輸出一個:androiddebugkey, 2010-4-20, PrivateKeyEntry,
認證指紋 (MD5): DA:29:11:13:D2:D2:0F:87:8E:08:22:6C:0D:4D:51:30

3、開啟http://code.google.com/intl/zh-CN/android/maps-api-signup.html

  輸入上面獲得的MD5,按著順序進入自己的郵箱,獲得

 <com.google.android.maps.MapView
                 android:layout_width="fill_parent"
                 android:layout_height="fill_parent"
                 android:apiKey="*******************************"
 />

這個apiKey就是你要得到的。

4、在自己的應用程式的設定mapview的xml檔案中配置一下:


<com.google.android.maps.MapView android:id="@+id/map"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:apiKey="*********************************************"
                android:clickable="true"
                android:focusable="true"
                android:nextFocusDown = "@+id/map"
                android:nextFocusLeft = "@+id/map"
                android:nextFocusRight = "@+id/map"
                android:nextFocusUp = "@+id/map"
                />
一切ok,這樣地圖就出來了。

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.