调用了百度地图,按着指导来的,跑不出来,请各位亲们帮帮忙看一下咋回事呢
以下是logcat内容:
FATAL EXCEPTION: main
Process: com.example.car10, PID: 20142
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.car10/com.example.car10.activity_main}: java.lang.NullPointerException: Attempt to invoke virtual method 'void com.baidu.location.LocationClient.registerLocationListener(com.baidu.location.BDAbstractLocationListener)' on a null object reference
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3449)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3601)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:85)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2066)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:223)
at android.app.ActivityThread.main(ActivityThread.java:7656)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void com.baidu.location.LocationClient.registerLocationListener(com.baidu.location.BDAbstractLocationListener)' on a null object reference
at com.example.car10.activity_main.onCreate(activity_main.java:105)
at android.app.Activity.performCreate(Activity.java:8000)
at android.app.Activity.performCreate(Activity.java:7984)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1309)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3422)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3601)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:85)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2066)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:223)
at android.app.ActivityThread.main(ActivityThread.java:7656)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
2022-04-14 15:33:42.489 20142-20142/com.example.car10 I/Process: Sending signal. PID: 20142 SIG: 9
![](https://profile-avatar.csdnimg.cn/default.jpg!4)
Android中调用百度地图失败
- 写回答
- 好问题 0 提建议
- 追加酬金
- 关注问题
- 邀请回答
-
5条回答 默认 最新
- weixin_42120514 2022-04-14 16:24关注
activity_main.java:105
LocationClient.registerLocationListener的LocationClient对象为空解决 无用评论 打赏 举报
悬赏问题
- ¥20 c语言写的8051单片机存储器mt29的模块程序
- ¥60 求直线方程 使平面上n个点在直线同侧并且距离总和最小
- ¥50 java算法,给定试题的难度数量(简单,普通,困难),和试题类型数量(单选,多选,判断),以及题库中各种类型的题有多少道,求能否随机抽题。
- ¥50 rk3588板端推理
- ¥250 opencv怎么去掉 数字0中间的斜杠。
- ¥15 这种情况的伯德图和奈奎斯特曲线怎么分析?
- ¥250 paddleocr带斜线的0很容易识别成9
- ¥15 电子档案元素采集(tiff及PDF扫描图片)
- ¥15 flink-sql-connector-rabbitmq使用
- ¥15 zynq7015,PCIE读写延时偏大