Run Baidu map demo under Android studio

1. Obtain AK

Visit http://lbsyun.baidu.com/index.php?title=androidsdk , remember to log in to your Baidu account, click Get Key -> Create Application , you will see the following interface:
Insert picture description here

  1. Fill in the application name

  2. Application type selection Android SDK

  3. Release version of SHA1:
    Windows+R open cmd, cd into .android , enter keytool -list -v -keystore debug.keystore and press Enter, the SHA1 code will appear under normal circumstances , if the following situations occur:
    Insert picture description here
    cd into the folder where keytool is located, In the java installation path, enter keytool.exe -list -keystore C:\Users\JX_Huang.android\debug.keystore and press Enter, fill in the keystore password: Android , note that the password will not be displayed.
    Insert picture description here
    You can get the SHA1 code
    Insert picture description here

  4. Development version SHA1:
    In fact, we just obtained the development version SHA1 . I just want to see the Baidu map demo instead of releasing it on the Android market. There is no need to release the SHA1 version , so you can leave it blank here.

  5. PackageName: Fill in the default baidumapsdk.demo
    can AndroidManifest.xml View Lane
    Insert picture description here

You can see your AK code after submitting

Insert picture description here

2. Download the Baidu map demo

Still visit http://lbsyun.baidu.com/index.php?title=androidsdk , click product download -> source code demo download
Insert picture description here
After decompression, we will use the folder BaiduMapsApiASDemo , copy it to your AndroidStudioProjects folder

Three, Android studio opens BaiduMapsApiASDemo

Three files need to be modified here. You can create a new project by yourself and record which version you have installed

  1. Outer build.gradle
    Insert picture description here
  2. build.gradle under app
    Insert picture description here
    Insert picture description here
  3. AndroidManifest.xml
    Insert picture description here
    fills the AK just obtained into android:value=" "/ >

Fourth, run

Click on the upper right corner Insert picture description here, if the following happens:
Insert picture description here
Open File-> Setting , search gradle , see the following interface
Insert picture description here
select Project-level projects of the Use local gradle Distribution's , Gradle Home Select gradle files in your Android studio installation folder path in the corresponding Version of the gradle folder, click OK , apply .
Insert picture description here
Then click Insert picture description here, wait a bit and found that pop-up warning, no other questions
Insert picture description here
will gradle.properties in android.enableBuildCache change the value of true
Insert picture description here
click on the Insert picture description heremake, successfully! ! !
Then click to run Insert picture description here, because my mobile phone installed it, so here I choose the emulator to
Insert picture description here
come out of the Baidu map demo interface, and get it done.
Insert picture description here

Guess you like

Origin blog.csdn.net/Huang_JinXin/article/details/95391598