行业导航范例的 showinfo 空指针报错

0 投票

如果注释showinfo倒是可以运行软件但用不了功能,麻烦了,谢谢

Process: com.example.nade, PID: 15090
    java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.nade/com.example.nade.MainActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'void com.example.nade.MyApplication.showInfo(java.lang.String)' on a null object reference
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2946)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3081)
        at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
        at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
        at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1831)
        at android.os.Handler.dispatchMessage(Handler.java:106)
        at android.os.Looper.loop(Looper.java:201)
        at android.app.ActivityThread.main(ActivityThread.java:6810)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:547)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:873)
     Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void com.example.nade.MyApplication.showInfo(java.lang.String)' on a null object reference
        at com.example.nade.MainActivity.openWorkspace(MainActivity.java:165)
        at com.example.nade.MainActivity.onCreate(MainActivity.java:139)
        at android.app.Activity.performCreate(Activity.java:7224)
        at android.app.Activity.performCreate(Activity.java:7213)
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1272)
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2926)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3081)
        at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
        at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
        at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1831)
        at android.os.Handler.dispatchMessage(Handler.java:106)
        at android.os.Looper.loop(Looper.java:201)
        at android.app.ActivityThread.main(ActivityThread.java:6810)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:547)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:873)
2021-04-13 16:09:07.890 15090-15150/com.example.nade E/LogInfoService: Get VideoList Request Failed....

4月 13 分类:  67次浏览 | 用户: ar_boy 才疏学浅 (14 分)
修改于 4月 13 用户:ar_boy

1个回答

0 投票
您好,showinfo只是一个输出弹出信息的类,您那边看下MyApplication这个类是不是修改了什么,注释掉该方法是不影响功能的。注释掉后无法使用你可以看下具体报什么错误
4月 13 用户: 董懿鑫 登峰造极 (8,230 分)

问题应该是工作空间打开失败,但basedemo是能正常运行的,是哪的路径有问题吗

...