在模拟器中正常使用Google Map之前需要提供一个 APIKey (密钥),否则在MapView中只能看到网格,没有任何地图信息。
下边我们就介绍如何正确取到自己的APIKey (密钥):
在介绍具体步骤之前,先要了解APIKey (密钥)放置的位置,
android:layout_width="fill_parent" android:layout_height="fill_parent" android:apiKey="密钥" />
密钥保存在(Main.xml)中:
具体操作步骤:
- 先找到keystore (解释:是一个密码保护的文件,用来存储密钥和证书。),运行Eclipse,打开Preferences对话框,在Android -> build中可以看到Keystore的存放路径:例如:C:Documents and Settings×××Local SettingsApplication DataAndroiddebug.keystore
- 启动Command Prompt. 使用Keytool命令(keytool.exe存放在Java/bin目录下)。完整的命令行:>keytool -list -alias androiddebugkey -keystore (debug.keystore的路径) -storepass android -keypass android
- 运行命令后可以看到生成出来的MD5 fingerprint(MD5 认证指纹)如图所示。
- 确 保已经拥有Google账户并登录到Android Maps API Key Signup,将MD5 fingerprint拷贝到(My certificate’s MD5 fingerprint),点击Generate API Key。
- 看到如下页面,0Nh7Q8krfhedftOI7tc83O6vyFusfo0FGNQwhQA 就是我们要添加到android:apiKey=”密钥”中的内容。
Keytool 的参数介绍:
| 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. |
其它类似资源(External):Android-ER->Obtaining a Maps API Key
Posted in Resource, Tutorial |




