Project Record - Develop Google Maps App for Saudi Client Android

Recently, the application for Saudi customers needs to use maps, so the Baidu map that is commonly used can not be used, so I have to replace it with Google Maps. As a result, many pits were encountered during the development process, and it took a lot of time to finally get it done. Here are a few key points recorded here, so that students have a reference.

1. Learn to use the Internet in science

This is a necessary skill for students who are engaged in Android. I won't say more here.

2. Prepare the necessary development environment

1. First, you need to install the GoogleAPI and GooglePlay images in your AndroidSDK.

2. The most convenient debugging method is to use an emulator, so you need to create an emulator image that includes Google services. Of course, you need to use the Internet scientifically when the emulator is running.

3. If you are using a real phone to test, it is estimated that you need to toss a bit. All licensed mobile phones in China have blocked google services. My phone is Huawei Mate10, it took me a lot of work to successfully install Google Maps after rooting, I haven't tested it on other phones, so I don't know.

3. Start developing Google Maps application

The first step, of course, is to register a GoogleMapAPI development license. There are 2 ways to create

A. Select to create a new Google Map Activity directly in the project, as shown in the figure

After Finish, a resource file google_maps_apo.xml will be automatically created and opened. Note the dubug in parentheses.

The content of the file is as follows

 Copy the address in the red box to the browser to open the console of the development license key, and create a project as shown in the figure

Then create a key, and the following interface appears

Copy the key in the red box to the google_maps_apo.xml you just opened and replace the string with the name google_maps_key. So you can continue to write code according to the document.

But note here that this is a big hole.

After all the code is written and run, you will find that your program is normal in the simulator if everything goes well, but after installing it on the real machine, the following problems will occur:

The service on the screen that says GooglePlay needs to be updated. Heck. It took me a long time to find out that if an app using Google services is allowed on a real machine, it can only be a release version. The above process is the debug version. Therefore, only option B below can be used.

If you have any technical problems, welcome to join the group 523916260, there is a group of like-minded friends who can exchange and learn together, and there are Daniel with more than 10 years of work experience.

 

B. Create a release version of the app

a. First you need to create a development certificate for the release version. It can be created in AndroidStudio, as shown in the figure:

I won't say much about this process. Everyone Baidu.

b. Use the command keytool -list -keystore mykey.jks to view the SHA1 fingerprint of the certificate, as shown in the figure

Record your SHA1 fingerprint

c. Go to https://console.developers.google.com and create a project, as shown in the figure

Then create the key as shown:

Note: The package name to be filled here should be the same as the value of package in your manifests.xml file. The SHA-1 value is the SHA1 fingerprint of the release certificate you just copied.

d. Enable Google Maps Android API

e. Then get the license key you need. Copy it to the manifest.xml file:

f. Finally, use AS to generate a release-signed apk and install it on your phone, then you're done.

In the end, this solution worked successfully on my Huawei Mate10 mobile phone, but after sending it to the customer, the customer installed it on a ZTE mobile phone. It is also about to faint, and the domestic GRW can actually do it in Saudi Arabia? ? ?

Unauthorized reproduction is prohibited, if necessary, please contact the author, thank you!

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325261463&siteId=291194637