下面的错误是什么意思?

时间:2018-03-13 18:09:54

标签: android

   03-13 01:14:06.310 7780-7780/com.wube.wubewallpaper
 E/AndroidRuntime: FATAL EXCEPTION: main


Process: com.wube.wubewallpaper, PID: 7780
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.wube.wubewallpaper/com.wube.wubewallpaper.MainActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.ImageView.setImageResource(int)' on a null object reference
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2646)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2707)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1460)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6077)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:865)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755)
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.ImageView.setImageResource(int)' on a null object reference
at com.wube.wubewallpaper.MainActivity.onCreate(MainActivity.java:39)
at android.app.Activity.performCreate(Activity.java:6662)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1118)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2599)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2707) 
at android.app.ActivityThread.-wrap12(ActivityThread.java) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1460) 
at android.os.Handler.dispatchMessage(Handler.java:102) 
at android.os.Looper.loop(Looper.java:154) 
at android.app.ActivityThread.main(ActivityThread.java:6077) 
at java.lang.reflect.Method.invoke(Native Method) 

这些是日志 -

return color

1 个答案:

答案 0 :(得分:0)

"引起:java.lang.NullPointerException:尝试调用虚方法' void android.widget.ImageView.setImageResource(int)'在null对象引用"

您正在尝试设置不存在的内容。如果确实存在,请仔细检查所有括号的放置位置。如果这些甚至有些混乱,它将无法正常工作。