[Solved] Flutter Amap plug-in amap_location error: AmapLocationPlugin.java:287: error

1. Foreword

Plug in amap in use_ The location suddenly reported an error today. The project cannot run. The error prompt is as follows:

2. Error prompt

.../amaplocation/AmapLocationPlugin.java:287:Error: Unreported exception error Exception; it must be caught or declared in order to throw locationClient = new AMapLocationClient(getApplicationContext());

3. Cause investigation

After modifying the one-to-one communication without results and one-to-one search for information, I accidentally saw the discussion in the group and knew that it was caused by the problem of privacy policy. The temporary solution is not to use the latest Gaode com.amap.api: location. The latest privacy policy is available. The best solution should be to access the latest policy, which has not been implemented

4. Solution

1. Find AutoNavi’s amap_location package according to the above path, in flutter/.pub-cache/hosted/…, and copy it after getting it, and change the latest dependency in android/build.gradle. At present, I Here is changed to 5.5.1


2. Delete the example in the package, create the local plug-in file plugins in the project, put the plug-in package into yaml, and import the local plug-in

Execute pub get, the error disappears, and the project can run

Read More: