Flutter amap_location高德定位插件无法编译 编译出错 Xlint:unchecked new AMapLocationClient报错爆红问题

报错内容:
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;
        }
    }

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值