Android : Unfortunately, app has stopped -
i beginner android, trying run first application. there's error in log file , application terminated message "unfortunately, app has stopped"!
here java file:
public class mainactivity extends actionbaractivity { @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); button mclick=(button)findviewbyid(r.id.button1); mclick.setonclicklistener(new view.onclicklistener() { //@override @suppresslint("showtoast") public void onclick(view v) { // todo auto-generated method stub toast t = toast.maketext(mainactivity.this, r.string.hi, 3000).show(); } }); } }
and log has these errors:
04-19 18:50:02.200: e/androidruntime(792): fatal exception: main 04-19 18:50:02.200: e/androidruntime(792): process: com.example.test, pid: 792 04-19 18:50:02.200: e/androidruntime(792): java.lang.runtimeexception: unable start activity componentinfo{com.example.test/com.example.test.mainactivity}: java.lang.nullpointerexception 04-19 18:50:02.200: e/androidruntime(792): @ android.app.activitythread.performlaunchactivity(activitythread.java:2195) 04-19 18:50:02.200: e/androidruntime(792): @ android.app.activitythread.handlelaunchactivity(activitythread.java:2245) 04-19 18:50:02.200: e/androidruntime(792): @ android.app.activitythread.access$800(activitythread.java:135) 04-19 18:50:02.200: e/androidruntime(792): @ android.app.activitythread$h.handlemessage(activitythread.java:1196) 04-19 18:50:02.200: e/androidruntime(792): @ android.os.handler.dispatchmessage(handler.java:102) 04-19 18:50:02.200: e/androidruntime(792): @ android.os.looper.loop(looper.java:136) 04-19 18:50:02.200: e/androidruntime(792): @ android.app.activitythread.main(activitythread.java:5017) 04-19 18:50:02.200: e/androidruntime(792): @ java.lang.reflect.method.invokenative(native method) 04-19 18:50:02.200: e/androidruntime(792): @ java.lang.reflect.method.invoke(method.java:515) 04-19 18:50:02.200: e/androidruntime(792): @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:779) 04-19 18:50:02.200: e/androidruntime(792): @ com.android.internal.os.zygoteinit.main(zygoteinit.java:595) 04-19 18:50:02.200: e/androidruntime(792): @ dalvik.system.nativestart.main(native method) 04-19 18:50:02.200: e/androidruntime(792): caused by: java.lang.nullpointerexception 04-19 18:50:02.200: e/androidruntime(792): @ com.example.test.mainactivity.oncreate(mainactivity.java:29) 04-19 18:50:02.200: e/androidruntime(792): @ android.app.activity.performcreate(activity.java:5231) 04-19 18:50:02.200: e/androidruntime(792): @ android.app.instrumentation.callactivityoncreate(instrumentation.java:1087) 04-19 18:50:02.200: e/androidruntime(792): @ android.app.activitythread.performlaunchactivity(activitythread.java:2159) 04-19 18:50:02.200: e/androidruntime(792): ... 11 more
can spot problem?
Comments
Post a Comment