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:
-
Fill in the application name
-
Application type selection Android SDK
-
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:
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.
You can get the SHA1 code
-
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. -
PackageName: Fill in the default baidumapsdk.demo
can AndroidManifest.xml View Lane
You can see your AK code after submitting
2. Download the Baidu map demo
Still visit http://lbsyun.baidu.com/index.php?title=androidsdk , click product download -> source code demo download
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
- Outer build.gradle
- build.gradle under app
- AndroidManifest.xml
fills the AK just obtained into android:value=" "/ >
Fourth, run
Click on the upper right corner , if the following happens:
Open File-> Setting , search gradle , see the following interface
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 .
Then click , wait a bit and found that pop-up warning, no other questions
will gradle.properties in android.enableBuildCache change the value of true
click on the make, successfully! ! !
Then click to run , because my mobile phone installed it, so here I choose the emulator to
come out of the Baidu map demo interface, and get it done.