Google Maps API V2 Android mobile phone development in China does not support Google Play Service-graphic tutorial

Source: Internet
Author: User
Tags certificate fingerprint android sdk manager contact google

Google Maps API V2 Android mobile phone development in China does not support Google Play service problems-graphic tutorial

The use of Google Maps in China is a headache and troublesome. I cannot understand why Google cannot be used as a map of Baidu.

Note: you can download a few APK packages on the market and then use the Google service after re-installation (the default is root.

Google Maps depends on Google Play service. Most mobile phones in China are not pre-installed with Google Play service. They cannot be installed independently. It takes several steps to install the system app after the root user.

The application API key method of V2 also makes debugging complicated. The developed jar package is not only available in normal import mode, but also needs to be imported into the project, which is much more complicated than other functions, I searched for a lot of information on the Internet. After I tested a lot of problems, I finally saw the map on my mobile phone. Here I will record it for 2013-03-25. (methods that can be used in the future may not work ).

Export the latest APK on your mobile phone to your blog and share the googleservice-related apk-20130325.zip.

Http://files.cnblogs.com/zdz8207/google%E6%9C%8D%E5%8A%A1%E7%9B%B8%E5%85%B3apk-20130325.zip

Official Address

A preliminary introduction to Google Maps Android API V2:
Https://developers.google.com/maps/documentation/android/
Introduction
Https://developers.google.com/maps/documentation/android/intro

========================================================== ==============

Procedure:

1. Download Google Play Services SDK: Open Android SDK manager to download the SDK.

Update the SDK content to the bottom. The download will go to the extras directory of your SDK directory. The specific path is related to your environment. For example, move the mouse to see it.

Ii. Apply for an API key

1. Obtain the fingerprint of the Certificate. There are two types of digital certificate: Debug and release.
Debug keystore file Debug. keystore for local debugging.
By default, it is stored together with the Virtual Machine AVD. You can also view it through the default debug keystore in Windows> preferences> android in eclipse.
Release is the keystore generated by publishing an application.
Switch to the bin directory of your installed JDK In the CMD command line and enter the following command (replace the path with your own ):
Keytool-v-list-keystore E: \ Android \ AVD \. Android \ Debug. keystore

The default password of DEBUG. keystore is Android, and your own signature file is your own password, which is the same as the password entered during release.
View the content in sha1 in "Certificate fingerprint". This content is written down and will be used later.
As follows:

2. Create a Google Maps API key

Https://code.google.com/apis/console
You need to log on first. The page for creating an API project will appear when you use it for the first time.
Click Create project to go to the Services page. on this page, select the API you want to use. Select Google Maps Android API V2.
Go to the confirm service terms page. After accepting the request, select "API access" in the list on the left of the displayed page, and click Create new Android key.

In the pop-up dialog box, fill in the sha1 authentication fingerprint and the package Life of the program, separated by semicolons (the package Life of the Google map V2 sample program is com. example. mapdemo ):
C6: 3D: DB: 7b: 1c: 07: FD: 5A: 53: E0: 85: 28: 3D: D1: 5f: Fe: FF: 8e: D1: 38; com. example. mapdemo
Click the create button to create a new API key:
Key for Android apps (with certificates)
API key:
Aizasydfglwpvnj33qxkvhpy7mxrhbnux29j42y
Android apps:
C6: 3D: DB: 7b: 1c: 07: FD: 5A: 53: E0: 85: 28: 3D: D1: 5f: Fe: FF: 8e: D1: 38; com. example. mapdemo
Activated on: Mar 25,201 3 AM

 

Configure the API key generated above to androidmanifest. xml
<Meta-data
Android: Name = "com. Google. Android. Maps. v2.api _ key"
Android: value = "aizasydfglwpvnj33qxkvhpy7mxbmp nux29j42y"/>

Open the API function in the service, especially the android API V2. Otherwise, the requested key cannot be used.

 

3. Import the project

In eclipse, choose File> Import, Android> existing Android code into workspace. (Note: It's Android> existing Android code into workspace, not General> existing projects into workspace, otherwise it cannot be imported), copy it to your working directory,Note: This project and the maps project must be in the same folder or Workspace; otherwise, an error occurs.

Import<Android-SDK-Folder>/extras/Google/google_play_services/samples/maps note: the new version of eclipse cannot be copied to the workspace before being imported. Otherwise, an error is returned.

In eclipse, select File> Import, Android> existing Android code into workspace to import the program to eclipse. (Note: Here is Android> existing Android code into workspace, rather than general> existing projects into workspace. Otherwise, a large number of errors may occur .)

A large number of errors are found after the import. Solution

1. Delete options_demo.xml multimap_demo.xml under Res \ Layout to delete the corresponding class and modify mainactivity.

2. Create libs folder and import android-support-v4.jar

3. Modify androidmanifest. XML to enter the applied API key,

Note that your package name must be the same as the application name. After modifying the package name, you must apply again. Of course, debug. if the keystore is different, you have to apply again. That is to say, you cannot use this key here.

<Meta-data
Android: Name = "com. Google. Android. Maps. v2.api _ key"
Android: value = "aizasydfglwpvnj33qxkvhpy7mxbmp nux29j42y"/>

4. Import the jar package of the google-play-services.jar, right-click your project, select Properties, choose android on the left, and then add the google-play-services_lib in the library below.

 

Note: It must be turned into green after being checked. In the current situation, it can be turned off and then it may become red again. The reason should be the path problem, as mentioned above, two projects must be in the same workspace.

In addition, Google Play on the mobile phone must be updated to the latest version. Otherwise, the first operation will prompt you to update it before you can use it.

My running effect:

Many problems have been encountered during the testing process. Other problems may occur in different environments and models. The main points of the problems I encountered are described above. The following are two exceptions with many errors.

03-25 13:09:00. 265: E/androidruntime (16215): Java. Lang. noclassdeffounderror: COM. Google. Android. GMS. r$ styleable

03-25 15:45:19. 311: E/Google Maps Android API (10212): failed to load map. cocould not contact Google servers.

Finally, in order to facilitate the export of the latest APK on your mobile phone to the blog, we shared the apservice-related apk-20130325.zip.

Send the code of the two projects imported to the workspace. Because the key is different from the environment, other users cannot import the project. Therefore, they can only make reference.

Google-play-services_lib.zip (maps.zip)

========================================================== =

Some feedback collected

Blogger, my VM runs a map in English version to see where the place names are controlled at noon. Is there a map running out on the mobile phone after the release of the blog release version? After I created a private certificate and applied for an API key to replace the key with the sha1 in it, a blank map is displayed on the mobile phone. Only the +-two standard package names match. I am a newbie. My Private Key Map is generated for the first time and cannot be displayed. I suspect that my certificate has a problem ..
---------------------------------------------------------
The version of the map is related to the language set by the mobile phone or virtual machine. If you set the language to Chinese, the map will become Chinese. This is what Google Map did.
There is no difference between the release version and the debug version, so the sha1 of the generated API key is different. You can use the private certificate generated by the ADT plug-in to export the signature.
You cannot run the release version certificate directly in eclipse. The debug signature is used for direct run. The release version must be installed with the official version of the export APK for normal use.

==========================================================

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.