Baidu Map Development of Android (i)

Source: Internet
Author: User
Tags sha1

1, registered Baidu developer account

2, apply key, note the development version SH and the release version of SH

get the development version of SHA1:

Input command: keytool-list-v-keystore debug.keystore, enter
Enter KeyStore Password: Android (system default) carriage return.

. Get the release version SHA1:to create your own signature file  

Select the Build->generate signed APK in the Android studio software. Click on the Next button

Here you can choose Create new Key store or choose Existing Key Store, select the existing KeyStore file is also possible, directly select, here, I introduce the steps to create a new KeyStore, click Create New Key Store button,

Key Store Path: Select the file path and name of the KeyStore.
Password: Password
Confirms: Enter the password again
Alias: Aliases
Password:key's password
Confirms: Enter the password again
Validity (years): Validity period of the key
First and last name: your name
Organizational unit: Unit
Organization: Organization
City or Locality: cities or locations
State or province: Province
Country Code (XX): Country
After completion, click "OK" button to return to the Generate signed APK interface, this time found the interface key store password, key alias, key password has been automatically filled out,
Click "Next" button, the Enter Master password interface appears (some may not appear this interface),

Fill in the password, click "OK" button,

The option for Build type is release, and also remember to tick the signature versions option. Click the Finish button to create the KeyStore file for the development version here.

View the release version of SHA1

Enter the command: Keytool-list-v-keystore "Create the address of the KeyStore file for the release", enter.
Enter KeyStore Password: What is set above, what to fill in here.

This will see the release version of SHA1.
The published version and the development version of SHA1 are filled into the corresponding input box. then click Submit.

3. Download so and jar packages online and import them into the project

4, Configuration Build.gradle

Add the following statement to the Build.gradle of the project:

Android {   ...    Sourcesets {        main {            jnilibs.srcdirs = [' Libs '}        }    }

Androidmanifest.xml
Permission Additions

To use Baidu Map, you need a lot of permissions, permissions to add to the manifest file in the Androidmanifest.xml, the required permissions are

<!--This permission is used for network positioning--<Uses-permissionAndroid:name="Android.permission.ACCESS_COARSE_LOCATION"/><!--this permission to access GPS location--<Uses-permissionAndroid:name="Android.permission.ACCESS_FINE_LOCATION"/><!--used to access WiFi network information, WiFi information is used for network location--<Uses-permissionAndroid:name="Android.permission.ACCESS_WIFI_STATE"/><!--get carrier information to support interfaces that provide operator information--<Uses-permissionAndroid:name="Android.permission.ACCESS_NETWORK_STATE"/><!--this permission to get access to WiFi, WiFi information is used for network location--<Uses-permissionAndroid:name="Android.permission.CHANGE_WIFI_STATE"/><!--to read the current state of the phone--<uses-permission android:name="Android.permission.READ_PHONE_STATE"/><!--write extended storage, write data to the expansion card, For writing offline location data-<uses-permission android:name="Android.permission.WRITE_EXTERNAL_STORAGE"/ ><!--access network, network location needs Internet--<uses-permission android:name=" Android.permission.INTERNET "/><!--SD card Read permissions, users write offline location data--<uses-permission Android : Name="Android.permission.MOUNT_UNMOUNT_FILESYSTEMS"/>        
Service Additions

Need to add a Baidu remote service to the application in the manifest file

<service    android:name="com.baidu.location.f" android:enabled="true" android:process=":remote" ></service>
Add secret Key

The secret key is also added in the application in the manifest file

<meta-data    android:name="com.baidu.lbsapi.API_KEY"    android:value="your api-key" />


Baidu Map Development of Android (i)

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.