报错内容:
E:\flutter\flutter.pub-cache\hosted\pub.flutter-io.cn\amap_location-0.2.0\android\src\main\java\com\jzoom\amaplocation\AmapLocationPlugin.java:227: ����: δ������쳣����Exception; ���������в���������Ա��׳�
locationClient = new AMapLocationClient(getApplicationContext());
^
ע: E:\flutter\flutter.pub-cache\hosted\pub.flutter-io.cn\amap_location-0.2.0\android\src\main\java\com\jzoom\amaplocation\AmapLocationPlugin.javaʹ����δ������ȫ�IJ�����
ע: �й���ϸ��Ϣ, ��ʹ�� -Xlint:unchecked ���±��롣
1 ������
FAILURE: Build failed with an exception.
What went wrong:
Execution failed for task ‘:amap_location:compileDebugJavaWithJavac’.
Compilation failed; see the compiler error output for details.
Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
Get more help at https://help.gradle.org
BUILD FAILED in 12s
Gradle task assembleDebug failed with exit code 1
Exited (sigterm)
第一种:
进入Flutter环境下,找到amap_location依赖,打开路径:【你的flutter安装磁盘】:\flutter.pub-cache\hosted\pub.flutter-io.cn\amap_location-0.2.0\android\src\main\java\com\jzoom\amaplocation的AmapLocationPlugin.java的文件。
在private boolean startup(Map arguments)的函数里,初始化AMapLocationClient高德定位服务类之前,加上官方示例的代码
AMapLocationClient.updatePrivacyShow(getApplicationContext(),true,true);
AMapLocationClient.updatePrivacyAgree(getApplicationContext(),true);
强制同意授权隐私协议接口。
附上官方说明及完整代码:
高德官方链接:https://lbs.amap.com/api/android-location-sdk/guide/create-project/dev-attention#t1
完整代码:
private boolean startup(Map arguments) {
synchronized (this){
if(locationClient==null){
AMapLocationClient.updatePrivacyShow(getApplicationContext(),true,true);
AMapLocationClient.updatePrivacyAgree(getApplicationContext(),true);
try {
locationClient = new AMapLocationClient(getApplicationContext());
}catch (Exception e){
}
//设置定位参数
AMapLocationClientOption option = new AMapLocationClientOption();
parseOptions(option,arguments);
locationClient.setLocationOption(option);
//将option保存一下
this.option = option;
return true;
}
return false;
}
}