首页 / 浏览问题 / 移动GIS / 问题详情
行业导航Network网络数据显示为空
8EXP 2024年08月08日

调用了,截图的时候注释掉了

Android studio报错:2024-08-08 09:41:58.160 10822-10822/com.example.pocket_park E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.example.pocket_park, PID: 10822
    java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.pocket_park/com.example.pocket_park.function.lead.LeadActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'com.supermap.data.Datasets com.supermap.data.Datasource.getDatasets()' on a null object reference
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:4311)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:4459)
        at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:103)
        at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:139)
        at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:96)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2855)
        at android.os.Handler.dispatchMessage(Handler.java:108)
        at android.os.Looper.loopOnce(Looper.java:226)
        at android.os.Looper.loop(Looper.java:328)
        at android.app.ActivityThread.main(ActivityThread.java:9236)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:594)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1099)
     Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'com.supermap.data.Datasets com.supermap.data.Datasource.getDatasets()' on a null object reference
        at com.example.pocket_park.function.lead.LeadActivity.initNavigation2(LeadActivity.java:531)
        at com.example.pocket_park.function.lead.LeadActivity.onCreate(LeadActivity.java:358)
        at android.app.Activity.performCreate(Activity.java:8964)
        at android.app.Activity.performCreate(Activity.java:8921)
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1456)
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:4287)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:4459) 
        at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:103) 
        at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:139) 
        at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:96) 
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2855) 
        at android.os.Handler.dispatchMessage(Handler.java:108) 
        at android.os.Looper.loopOnce(Looper.java:226) 
        at android.os.Looper.loop(Looper.java:328) 
        at android.app.ActivityThread.main(ActivityThread.java:9236) 
        at java.lang.reflect.Method.invoke(Native Method) 
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:594) 
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1099) 

1个回答

根据报错Datasource.getDatasets()出错,建议在断点中使用Datasource.getDatasets().getCount获取下数据集数量,再用datasets.get(int index)根据序号获取数据集查看网络数据集是否存在
3,680EXP 2024年08月08日
...