The company’s H5 packaged APP project requires the use of AutoNavi maps, which can be used to debug Android and Apple phones with HBuilderX real machine, but after cloud packaging, Android phones cannot open the map.
-
If you encounter problems, first want to see if there are any errors. For Android phones, you can download Google Chrome on the phone, then open the developer option of the phone settings, and connect the phone to the computer via USB. Browse chrome://inspect/#devices on the computer Google browser, as shown in the figure below.
Special attention should be paid to
1. The debug: "true" in the manifest.json needs to be set, otherwise the APP cannot be seen.
2. Click inspect to check and debug, there will be 404, which can be solved by overturning the wall. -
Then I found that the code that reported the error was 7. It was found that the key configured by SKD had a problem.
I only applied for the key of js api from AutoNavi, which was quoted in index.html. Then the IOS and Android configured by SKD also use this key, but The Android key also needs to apply for the Android key (IOS is estimated to have to re-apply for the KEY, and IOS is not covered for the time being).
<script type="text/javascript" src="https://webapi.amap.com/maps?v=1.4.15&key=6c6732d9e4bd450864be00927*****"></script>
- The task here becomes the key to apply for Android.
The steps are as follows:
1. First apply for your own certificate in HBuilderX cloud packaging, refer to https://ask.dcloud.net.cn/article/35777 , check the free certificate, there will be SHA1 in it.
2. PackageName is the name of the Android package packaged by the cloud.
3. Get the key value of Android, fill it in the SKD configuration and it will be OK.
- Pack it again and open the page to display the map normally. Remember to change the debug mode in the above configuration back to fasle or delete it.