Gold Map API Invalid_user_scode issues and KeyStore issues

Source: Internet
Author: User
Tags sha1

This article will introduce three questions to you today:

1, Invalid_user_scode problem occurred when accessing API

First big problem, invalid_user_scode problem when accessing the high-gold map API

Because the project needs to access the high-gold map API, there will be similar problems when accessing other APIs, the following problems occurred during the positioning

The run-time log information is as follows

As you can see, there are two reasons for locating failures:

1, the error code is 10, the location service failed to start.

2, error code is 7,key error.

According to the official use of the German map of the introduction of the document, related issues to deal with

Issue 1: Service failed to start: Check the manifest profile Androidmanifest.xml, the service is configured to complete as follows

<service android:name= "Com.amap.api.location.APSService"/>

Later compared to the German map to the demo only found that because the less add a jar package, such as the blue selected package is not added

After adding, run the program to locate the operation, log information is as follows:

From the information printed by log, you can see three points:

1, location service startup failure has been resolved and has been successfully started.

2,key error problem still exists

3, when the positioning method is called every other time to do a location

Next, you need to resolve issue 2.

Problem 2:key Error, official document says, please double check key binding SHA1 with signed APK SHA1 is consistent:

In solving this problem, I found that I made two wrong mistakes:

First, forget to add the code in the Build.gradle file:

Android {    Signingconfigs {        //debug version of KeyStore        Debug {            storefile file ("Location of KeyStore files")            Storepassword "You specified the password"            Keyalias "in the creation of KeyStore when you fill in the alias"            Keypassword "you specify the password"        }        //release version of KeyStore        Release {            storefile file ("Location used KeyStore files")            Storepassword "The password you specified"            Keyalias " When you created the KeyStore file you wrote the alias "            Keypassword" you specified the password "}        }    }


Second, when applying for key, my SHA1 fill in the format error, the error is as follows:

The correct fill format is as follows:


In this case, my program has been able to achieve positioning, such as:

2, how to create your own keystore, and how to modify the release and beta version of KeyStore

Now discuss the second big question, how to create a KeyStore file, and how to modify the KeyStore for both the release and the development version:

Take Androidstudio as an example to create a KeyStore file:

Next:

Then, where the red line is labeled in the figure, it must be remembered, because it needs to be used in the program

After completing the above steps, your KeyStore file is created successfully, next, you need to use in the Build.gradle file, the text has been handed over, no longer repeat, to the different keystore files to make corresponding changes, But keep in mind that when your KeyStore file is modified, it will mean that the SHA1 of your program will change, so be sure to remember to configure your app for updates on the web.

3, how to view the SHA1 security code for the KeyStore file

The third big question, after having the Keystroe file, how to see the so-called SHA1 code?

Need to use CMD, (if you do not know how to open cmd, as well as the configuration of the JDK, please Baidu, Bo Master no longer say more)

Enter the following command in CMD: Keytool-list-keystore <keystore location >

Then enter the password to get SHA1:

Gold Map API Invalid_user_scode issues and KeyStore issues

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.