android--Baidu Map Key application + Environment configuration (i)

Source: Internet
Author: User

Introduction

Before using the Baidu Map SDK to provide you with a variety of LBS capabilities, you need to obtain the Baidu Map mobile version of the development key, the key and your Baidu account associated. Therefore, you must have a Baidu account before you can obtain the development key. Also, the key is related to the name of the process you created, please refer to the following for details.

The application address for key is: Http://lbsyun.baidu.com/apiconsole/key

Attention:

1. In order to provide users with a more secure service, the Android SDK has introduced a new key verification system since the v2.1.3 version. Therefore, when you choose to use the v2.1.3 and later version of the SDK, you need to go to the new Key application page to make a new key application; (Old and new keys cannot be used)

2. The new key mechanism, each key only and only for 1 application validation is valid, that is, the key configuration link used in the package name matching application is valid. Therefore, multiple applications "including multiple package names" need to apply for more than one key, or 1 keys to configure multiple times;

3. Under the new key mechanism, if you need to use the same project in the same time Baidu map, positioning, navigation SDK can share the same key;

4. If you use the LBS cloud service during the development of the Android SDK, you need to request a separate key for the server type for the service;

Application ProcedureLogin Baidu Account

Visit the API console page, if you are not logged in Baidu account, will enter the Baidu account login page, such as:


Login API Console

The login will jump to the API console service, as follows:

Create an app

Click "Create App", go to the Create AK page, enter the app name, and change the app type to: "Android SDK":

Configure the App

After the app type is selected as "Android SDK", you need to configure the app's security code as shown in:

Get Security Code

The security code consists of the following rules: The SHA1 value of the Android signing certificate +packagename for example:


SHA1:bb:0d:ac:74:d3:21:e1:43:67:71:9b:62:91:af:a1:66:6e:44:5d:75


Package Name:Com.baidumap.demo


Android app gets the package name PackageName, depending on the development tools, get location is different

1. Using Eclipse Development

The package name is the name defined by the Android application itself in Androidmanifest.xml, for example:

2. Development using Android Studio

The package name needs to be queried for Applictionid in the file Build.gradle, for example:

There are two ways to get the SHA1 value of an Android signing certificate:

The first method: using Keytool

1th step: Run into the console

2nd step: Navigate to the. Android folder, enter CD. Android

3rd Step: Enter Keytool-list-v-keystore Debug.keystore, you will get three kinds of fingerprint certificate, select the SHA1 type of certificate (key password is Android), for example:

Where Keytool is the JDK's own tool; Keystorefile for Android signing certificate file

Second approach: In Eclipse, see directly in ADT 22

If you use ADT 22, you can view it directly in Eclipse: Android---build, Windows---preferance. As shown:

Where the "SHA1 fingerprint" value is the SHA1 value of the Android signing certificate

successfully created key

After entering the security code, click "OK" to complete the application configuration work, you will get a key created, please keep the key you requested. Here you can use the new key to complete your development work.

Configuring the Environment and publishing the Android SDK
Development Tools

There are many Android development tools, where we recommend that you use Eclipse and Android studio as your own development tool. Below we will introduce the project configuration method for the Map SDK for Eclipse and Android studio respectively.

Eclipse Engineering Configuration Methods

The first step: Create a new Libs folder in the project, copy the Baidumapapi_vx_x_x.jar in the development package to the Libs root directory, copy libbaidumapsdk_vx_x_x.so to Libs\ Armeabi Directory (the official website has already had these two files, if you want to integrate into your project, you need to add it), copy the completed project catalog as shown;



The second step: select "Add External JARs" in the project properties->java Build path->libraries, choose Baidumapapi_vx_x_x.jar, and return when determined.

With the above two steps, you will be able to use the Baidu Map SDK to provide you with all the functions.

Note: Because of the ADT plugin upgrade, if you are using Eclipse ADT 22, you need to set the development environment accordingly, as follows:

1. Select project in Eclipse, right-click Properties->java Build path->order and Export to make Android Private libraries tick;

2. Project-clean-> clean all.

Android Studio Engineering Configuration Method

The first step: in the project App/libs directory into the Baidumapapi_vx_x_x.jar package, in the src/main/directory under the new Jnilibs directory, the project will automatically load the SRC directory of so Dynamic library, put into libbaidumapsdk_vx_x _x_x.so as shown, note that the first 3-bit version number of the jar and so must be the same, and that the two files in the folder you downloaded once are guaranteed to be used without the jar or so of different functional components.

The configuration of so can also refer to the directory structure given by the demo, as shown in the app project path, create a new libs, and put in the Libs directory corresponding to the different CPU architecture so file. This project does not automatically load the so libs under the Gradle compile, by adding code: Jnilibs.srcdir ' libs ' to indicate that the path of so is the Libs path.

The second step: the project configuration also needs to integrate the jar package into its own project, as shown in the Libs directory. For each jar file, right-select the add as Library to import into the project. Corresponding to the jar file description that is dependent on the Build.gradle build project:

The configuration of the jar can also refer to the Eclipse method to do the following:

Menu bar Select File->project Structure.

In the Project Structure dialog box that pops up, select Module, and then click the Dependencies tab.

Click the green plus sign to select File dependency. Then select the jar package to be added to complete the above operation, in the Build.gradle file in the app directory, there will be the class library introduced, as shown in.

Please refer to the official demo for the Android Studio project configuration details.
Application Obfuscation

Integration with the application of the Map SDK, when packaging confusion, you need to note that the Map SDK-related methods can not be confused. The obfuscation method is as follows:

- class com.Baidu. ** {*; }-class VI. com. ** {*; }    -dontwarn com.Baidu.  **

Ensure that the Baidu class can not be confused, or there will be network unavailability and other runtime anomalies


android--Baidu Map Key application + Environment configuration (i)

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.