In the last few days, I have been learning how to develop Google Maps in Android.ProgramI have encountered some problems and made some detours due to my carelessness. Next, let me talk about some of my thoughts and feelings:
1. A map extension library is provided in the add-on pre-installed in the android SDK.Com. Google. Android. maps can be used to add powerful map functions to Android applications. It is located in F:/Android-SDK-Windows/add-ons/google_apis-7_r01/libs (that is, the installation path of your SDK below, here is just an example, I installed it on the drive F ). However, before using the android Maps API function, you need to apply for an android Maps API key.
2.Apply for an android Maps API key
There are many ways to solve this problem on the Internet. I tried to use it, but I was trying to get debug. the MD5 value of the keystore is troublesome and sometimes many errors occur. Follow these steps:
1) find the path of your Debug. keystore file.
The general certificate path is: Open eclipse, select windows ---> preference ---> Android ---> build, where the default debug keystore value is debug. the keystore path can also be obtained through other channels. This is not mentioned here, because this is a shortcut. Why not use it?
2) obtain the MD5 value of DEBUG. keystore.
First, go to the path where the Debug. keystore file is located under DOS. The above step has been obtained, and then run the command:
Keytool-list-keystore Debug. keystore)
You may be prompted to enter the password. Enter the default password "android" here to obtain the MD5 value.
3) obtain the Maps API key
Open the browser, enter the web site: http://code.google.com/intl/zh-CN/android/add-ons/google-apis/maps-api-signup.html (when, a lot of online, but also do this, but their Web site seems to have some problems, some of the book is not correct, this is their own through practice, such a URL is definitely not a question ). Of course, the premise is that you must have a Google account. If not, you can temporarily register one. Then, open the Google Page, enter the code, and perform step-by-step search. You can also find the URL that I wrote at the beginning. (I suggest you do better. If you eat ready-made things, you will never learn things, and you will not remember them very well. Therefore, you can find them step by step as I said ). On the open page, enter the MD5 fingerprint you obtained in step 2, select the agree protocol, and press the "generate API key" button to obtain the API key we have applied.
4) Add the followingCode:
<Com. Google. Android. Maps. mapview
Android: Id = "@ + ID/mapview01"
Android: layout_width = "fill_parent"
Android: layout_height = "fill_parent"
Android: apikey = "0vctgyqxdxhfzetwyivns-4ihkt8phkbbmhv2vg)
/>
5) Add the following lines of code in androidmanifest. xml:
Add the following code before <application/>:
<Uses-Permission Android: Name = "android. Permission. access_coarse_location"/>
<Uses-Permission Android: Name = "android. Permission. Internet"/>
These are all user permissions. You can go to androidapi to check the permissions, which are clearly explained.
At the same time, add the following code in <application/>:
<Uses-library Android: Name = "com. google. android. maps "/> (User library, remember, we use Google Maps, so we need to find them here, which are not available in Android sdks)
The above are some solutions when I learned how to use the android Maps API to develop a map application. With the help of the SDK documentation and some resources on the Internet, of course, many of them learned through reading books.
Let me talk about my problems and the causes of the errors:
1> follow the steps above to obtain the debug. the MD5 value of the keystore is very easy and can be obtained quickly. However, due to my carelessness, the obtained API key is actually incorrect, when the program runs on the simulator, some gray grids are displayed, instead of the map I want to see. This is caused by incorrect map API key values;
2> for Android sdk2.1 or future development, we recommend that you useMaps API key. Otherwise, some problems may occur. I didn't use the above URL at the beginning, which caused the value of the map API key to be incorrect.