The problem

I found Gord retreating today. Stop and see.

Autonavi 8.0.0+ added privacy-related content, causing initialization failure.

java.lang.Exception: Update Privacy Compliance updatePrivacyShow and updatePrivacyAgree are invoked before any INTERFACE of the SDK is invoked, and their values are both true. If incorrect Settings are used, crash risks occur. Before using the LOC SDK function, set whether to inform users of privacy policy popups

To solve

Before initialization, call updatePrivacyShow and updatePrivacyAgree API

try {
    ServiceSettings.updatePrivacyShow(context, true, true);
    ServiceSettings.updatePrivacyAgree(context,true);
    locationClient = new AMapLocationClient(context);
    
} catch (Exception e) {
    e.printStackTrace();
}
Copy the code

New problems

These two apis were added after 8.0.0, so the older versions are no longer available. Need to integrate with autonavi’s latest Api. Just set it to auto-update

/ / gold map implementation 'com. Amap. API: 3 dmap: latest. Integration' / / gold positioning implementation 'com. Amap. API: location: latest integration' / / gold search implementation 'com. Amap. API: search: latest integration' / / implementation 'com. Amap. API: search: 6.9.2'Copy the code

But why didn’t I just set it like this before, to write version 6.9.2? Because the new version of the search can not get the name of the area and the code Adcode equivalent document search for a long time, also did not find how to obtain these two values

Then I found the answer in the Interface documentation on the Web

Extensions must be set to all on the request parameter

Extensions must be set to all on the request parameter

So how do YOU set the extensions to all? Because gaode confused, the source code is abCD, so find quite laborious.

This parameter is found in poisearch.query.

query.setExtensions(PoiSearch.EXTENSIONS_ALL);
Copy the code

So far, gaode search data can be returned normally. If the other interface does the same thing, it can’t return all the data. Also find the request parameter and set the Extensions to all