申请Google Map API Key

开发Android应用程序,如果使用到GoogleMaps,须先向Google申请一组经过验证的Android Maps API Key,这组Key可以在多个应用程序中使用。


1,申请Android Maps API Key前,需先从开发环境中取得keystore的MD5编码,然后通过Google网站的签署,便可获得

debug.keystore文件路径可由Eclipse IDE中“Window - Preferences - Android - Build”中找到

$ keytool -list -alias androiddebugkey -keystore /home/cat/.android/debug.keystore -storepass android -keypass android
androiddebugkey, 2012-9-1, PrivateKeyEntry, 
认证指纹 (MD5): 97:33:40:5E:FD:XX:XX:XX:YY:YY:YY:ZZ:ZZ:ZZ:19:11

Keytool Option Description
-list Print an MD5 fingerprint of a certificate.
-keystore <keystore-name>.keystore The name of the keystore containing the target key.
-storepass <password>

A password for the keystore.

As a security precaution, do not include this option in your command line unless you are working at a secure computer. If not supplied, Keytool prompts you to enter the password. In this way, your password is not stored in your shell history.

-alias <alias_name> The alias for the key for which to generate the MD5 certificate fingerprint.
-keypass <password>

The password for the key.

As a security precaution, do not include this option in your command line unless you are working at a secure computer. If not supplied, Keytool prompts you to enter the password. In this way, your password is not stored in your shell history.


如果下次需要再查看这个MD5值,可以通过$ keytool -list -keystore /home/cat/.android/debug.keystore命令,输入keystore密码:android得到

Keystore 类型: JKS
Keystore 提供者: SUN


您的 keystore 包含 1 输入


androiddebugkey, 2012-9-1, PrivateKeyEntry, 
认证指纹 (MD5): 97:33:40:5E:FD:XX:XX:XX:YY:YY:YY:ZZ:ZZ:ZZ:19:11


2,访问https://developers.google.com/android/maps-api-signup?hl=zh-CN,输入取得的MD5编码,申请Android Maps API Key

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


3,将获得的Android Maps API Key放入工程的layout文件中使用

    <com.google.android.maps.MapView
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/map_view"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_below="@+id/linearLayout2"
        android:apiKey="0mP5XXn2YY7wzy_2ZZc4OObP_WCQQX9hPPpLMMQ"
        android:clickable="true"
        android:enabled="true" >
    </com.google.android.maps.MapView>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值