Configuration of Google map API V2 on Eclipse

Source: Internet
Author: User
Tags android sdk manager
1. Install Google APIs corresponding to Android APIs in Android SDK manager and Google Play Service in extras below


2. Import google-play-service_lib

File-> Import-> existing Android code into workspace next step


Then select the google_play_services folder, generally in the android SDK \ extras \ google \ google_play_services \ libproject \ google-play-services_lib

My location is: D: \ Program Files \ Android-SDK \ extras \ google \ google_play_services \ libproject \ google-play-services_lib

And select copy projects into workspace.

 

Make sure that the folder of this library project and the project that uses this library are in the same folder.

Import completed

3. Create an Android Application Project

Right-click the project and choose Properties to open the properties of the project. Select Google APIs from Project Build target.



4. Under properties, select the imported google-play-service_lib from the library above



It can only be used when matching. If it is a Red Cross, you must check whether the paths are correct and whether they are in the same folder.

After the configuration is completed at this time, the map will be displayed on the interface, but at this time, make sure that the Google map demo can display the map.

5. Test Google map demo

You can also import the Google map demo at this time.

Select the Folder \ extras \ google \ google_play_services under Android SDK during import.

You can see a project named Google map. Just import it.

In this case, you can try to run the Google map demo.

At the same time, you also need to select copy projects into workspace, which should be in the same folder as the imported Library

At this time, I encountered some problems:

① Some files that use fragment will report errors to map xmln. In this case, right-click the project and choose Properties> android

Check whether the library below is a Red Cross. This is because the Map Library is not correctly imported. Click Add... select the Map Library and import it.

② Some activities do not recognize Android. Support. v4... these activities that use fragmentactivity report errors because the corresponding imported content is not found.

You can copy a android-support-v4.jar file from another program, create a libs folder, put this jar in the libs folder, this time should be no problem, if this problem is still not resolved, right-click-> properties, find build path, and select Add jar under the libraries tab... just select the JAR file.


③ If you cannot run the program during debugging on your mobile phone, an error will be reported because Google Play is not installed on your mobile phone. at this time, the drug confirmed that the mobile phone has already installed Google Play. If it is not installed, it would be better to download a mobile phone from the Internet and install it to the mobile phone, because it is said that most Chinese mobile phones do not have Google Play

When running, the map demo program will prompt you to download a Google Map Service from Google Play. After installation, the map will be displayed.

④ The map is not displayed. You should find androidmanifest. xml and find the following code because of API problems.

<Meta-data Android: Name = "com. Google. Android. Maps. v2.api _ key"

Android: value = "aizasycvgbr5in13nk2yybr7lhxttnxj3mrxqy4"/>

Because each program has a different API, this may be used after release, that is, export. Generally, you need to apply for the API by yourself because the API version for debugging is run in eclipse.

⑤ If the map cannot be correctly displayed, only the grid is displayed to make it wrong because the API is incorrect.

⑥ If the grid is not displayed, it is because the API is released or the debugging version is incorrect. You can apply for an API as required.

Note: The signature file is XXX. keystore, not used for debugging. keystore. These two versions are different. After applying for a new API with the sha1 key on the new computer, use the corresponding XXX. the final program of keystore export.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.