百度地图:Caused by: java.lang.IllegalArgumentException: marker's icon can not be null

报错信息:

java.lang.RuntimeException: Unable to start activity ComponentInfo{com.augurit.agmobile.agplant/com.augurit.agmobile.agplant.addpestinfo.AddInfoActivity}: java.lang.IllegalArgumentException: marker's icon can not be null
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2444)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2504)
        at android.app.ActivityThread.access$900(ActivityThread.java:165)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1368)
        at android.os.Handler.dispatchMessage(Handler.java:102)
        at android.os.Looper.loop(Looper.java:150)
        at android.app.ActivityThread.main(ActivityThread.java:5546)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:792)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:682)
     Caused by: java.lang.IllegalArgumentException: marker's icon can not be null
        at com.baidu.mapapi.map.MarkerOptions.icon(Unknown Source)
        at com.augurit.agmobile.agplant.addpestinfo.AddInfoActivity.initViewFromDraft(AddInfoActivity.java:366)
        at com.augurit.agmobile.agplant.addpestinfo.AddInfoActivity.onCreate(AddInfoActivity.java:256)
        at android.app.Activity.performCreate(Activity.java:6367)
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1110)
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2397)

提示报错代码段位置:366行

报错代码:

错误分析:

 Caused by: java.lang.IllegalArgumentException: marker's icon can not be null

代码里面明明写了icon,左边的预览图标都出来了!为什么还是报错?

试用了两种icon:1,png图片;2,矢量图片

当使用矢量图的时候就会出现这个错误,png图片则不会。

解决办法:

使用png,jpg图片试试,避免使用矢量图;

 

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值