BT连接时出现Android错误

时间:2017-01-08 11:02:53

标签: android

我是Android的初学者。我是一名PLC程序员,但我想为我的手机编写应用程序。我想通过Arduino远程控制RGB led。但是当我做出任何更改时,我都会遇到错误,而且我不知道这是什么。

  

E / AndroidRuntime:致命异常:主要                     过程:com.led.led,PID:7790                     java.lang.RuntimeException:无法启动活动ComponentInfo {com.led.led / com.led.led.ledControl}:   显示java.lang.NullPointerException                         在android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2412)                         在android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2470)                         在android.app.ActivityThread.access $ 900(ActivityThread.java:174)                         在android.app.ActivityThread $ H.handleMessage(ActivityThread.java:1307)                         在android.os.Handler.dispatchMessage(Handler.java:102)                         在android.os.Looper.loop(Looper.java:146)                         在android.app.ActivityThread.main(ActivityThread.java:5593)                         at java.lang.reflect.Method.invokeNative(Native Method)                         在java.lang.reflect.Method.invoke(Method.java:515)                         在com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run(ZygoteInit.java:1283)                         在com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1099)                         at dalvik.system.NativeStart.main(Native Method)                      引起:java.lang.NullPointerException                         在com.led.led.ledControl.onCreate(ledControl.java:121)                         在android.app.Activity.performCreate(Activity.java:5458)                         在android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1093)                         在android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2376)                         在android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2470)                         在android.app.ActivityThread.access $ 900(ActivityThread.java:174)                         在android.app.ActivityThread $ H.handleMessage(ActivityThread.java:1307)                         在android.os.Handler.dispatchMessage(Handler.java:102)                         在android.os.Looper.loop(Looper.java:146)                         在android.app.ActivityThread.main(ActivityThread.java:5593)                         at java.lang.reflect.Method.invokeNative(Native Method)                         在java.lang.reflect.Method.invoke(Method.java:515)                         在com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run(ZygoteInit.java:1283)                         在com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1099)                         在dalvik.system.NativeStart.main(本地方法)

1 个答案:

答案 0 :(得分:0)

当您尝试访问尚未定义的内容时,会发生NullPointerException。 喜欢例如。尝试在文本视图中设置文本,然后在活动中将其分配给xml中的id。