android studio Android emulator Gaode SDK locates network connection abnormality

background

A project was created using Amap SDK, and the following is the running interface:

When I clicked the "Start Positioning" button, the positioning information was not returned, but an error was reported:

Insert image description here

Open this URL according to the error prompt: https://lbs.amap.com/api/android-location-sdk/guide/utilities/errorcode , and find the error code 4 information, which shows a network problem.

Insert image description here

solve

I tried it, and the status of my virtual machine at this time is as follows:
1. You can open the Baidu page (www.baidu.com) in Google, and you can use Baidu to search for some content. For example, Baidu News can be viewed ;
2. The wifi of the virtual machine displays "Not connected to the network";
3. If the wifi is turned off, the data connection will display a message such as "Unable to connect to the network";

At first I thought it was because the virtual machine couldn't use GPS, so I tried to transfer a gpx file to the virtual machine, but it kept loading; later I thought it might be an abnormality in the virtual machine network (because the virtual machine wifi showed "Not connected to the network"), so I tried Follow the steps in this article (Portal: Android Studio emulator cannot access the network ). But when I reached the next step, I seemed to have discovered the cause of the exception: when I reported the error before, the target of my virtual machine was Google Play. Yes, I created a Google API again, and when I ran the program, I found that the above error message no longer appeared.

Insert image description here

The running results after switching to Google API:

Insert image description here

Insert image description here

Guess you like

Origin blog.csdn.net/Charonmomo/article/details/132698265