我正在开发一个Android应用程序,我已经在虚拟设备上进行了测试,但是当我尝试在真实设备上运行它时,我得到了以下错误。(实际上虚拟设备是Nexus One和真实设备是Xperia Z)。
08-16 15:27:15.815: D/AndroidRuntime(11178): Shutting down VM
08-16 15:27:15.815: W/dalvikvm(11178): threadid=1: thread exiting with uncaught exception (group=0x40d6cae0)
08-16 15:27:15.815: E/AndroidRuntime(11178): FATAL EXCEPTION: main
08-16 15:27:15.815: E/AndroidRuntime(11178): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.AndroidLightSensor/com.AndroidLightSensor.MainActivity}: java.lang.NullPointerException
08-16 15:27:15.815: E/AndroidRuntime(11178): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2194)
08-16 15:27:15.815: E/AndroidRuntime(11178): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2244)
08-16 15:27:15.815: E/AndroidRuntime(11178): at android.app.ActivityThread.access$600(ActivityThread.java:149)
08-16 15:27:15.815: E/AndroidRuntime(11178): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1246)
08-16 15:27:15.815: E/AndroidRuntime(11178): at android.os.Handler.dispatchMessage(Handler.java:99)
08-16 15:27:15.815: E/AndroidRuntime(11178): at android.os.Looper.loop(Looper.java:213)
08-16 15:27:15.815: E/AndroidRuntime(11178): at android.app.ActivityThread.main(ActivityThread.java:5092)
08-16 15:27:15.815: E/AndroidRuntime(11178): at java.lang.reflect.Method.invokeNative(Native Method)
08-16 15:27:15.815: E/AndroidRuntime(11178): at java.lang.reflect.Method.invoke(Method.java:511)
08-16 15:27:15.815: E/AndroidRuntime(11178): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:797)
08-16 15:27:15.815: E/AndroidRuntime(11178): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:564)
08-16 15:27:15.815: E/AndroidRuntime(11178): at dalvik.system.NativeStart.main(Native Method)
08-16 15:27:15.815: E/AndroidRuntime(11178): Caused by: java.lang.NullPointerException
08-16 15:27:15.815: E/AndroidRuntime(11178): at com.AndroidLightSensor.MainActivity.onCreate(MainActivity.java:45)
08-16 15:27:15.815: E/AndroidRuntime(11178): at android.app.Activity.performCreate(Activity.java:5104)
08-16 15:27:15.815: E/AndroidRuntime(11178): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
08-16 15:27:15.815: E/AndroidRuntime(11178): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2158)
08-16 15:27:15.815: E/AndroidRuntime(11178): ... 11 more
08-16 15:27:17.616: I/Process(11178): Sending signal. PID: 11178 SIG: 9
任何帮助? 如果有必要请告诉我复制代码。