java - App crashing in emulator -


i've searched plenty , have found nothing prevent error. making simple stopwatch application crashing in emulator when try , test it.

the code matters:

public class myactivity extends activity implements actionbar.tablistener {      /**      * {@link android.support.v4.view.pageradapter} provide      * fragments each of sections. use      * {@link fragmentpageradapter} derivative, keep every      * loaded fragment in memory. if becomes memory intensive,      * may best switch      * {@link android.support.v13.app.fragmentstatepageradapter}.      */      sectionspageradapter msectionspageradapter;      /**      * {@link viewpager} host section contents.      */     viewpager mviewpager;      @override     public void oncreate(bundle savedinstancestate) {         super.oncreate(savedinstancestate);         setcontentview(r.layout.activity_my);         button start;         final textview stopwatch_num;         final double mcount = 0.0;         start = (button)findviewbyid(r.id.start_button);         stopwatch_num = (textview)findviewbyid(r.id.timer_num);         start.setonclicklistener(new view.onclicklistener() {             @override             public void onclick(view view) {                 mcount = mcount + .01;                 stopwatch_num.settext(""+mcount);             }           }); 

inside onclicklistener, on first mcount, says "cannot assign value final variable 'mcount'".

the logcat:

06-13 19:29:04.280      851-851/martinproductions.time_me d/dalvikvm﹕ gc_for_alloc freed 60k, 10% free 3452k/3804k, paused 36ms, total 38ms 06-13 19:29:04.480      851-851/martinproductions.time_me d/dalvikvm﹕ gc_for_alloc freed 3k, 9% free 3670k/4028k, paused 21ms, total 21ms 06-13 19:29:04.500      851-851/martinproductions.time_me i/dalvikvm-heap﹕ grow heap (frag case) 6.283mb 2536936-byte allocation 06-13 19:29:04.540      851-861/martinproductions.time_me d/dalvikvm﹕ gc_for_alloc freed <1k, 6% free 6148k/6508k, paused 37ms, total 37ms 06-13 19:29:04.720      851-851/martinproductions.time_me d/androidruntime﹕ shutting down vm 06-13 19:29:04.720      851-851/martinproductions.time_me w/dalvikvm﹕ threadid=1: thread exiting uncaught exception (group=0xb1ab0ba8) 06-13 19:29:04.730      851-851/martinproductions.time_me e/androidruntime﹕ fatal exception: main     process: martinproductions.time_me, pid: 851     java.lang.runtimeexception: unable start activity componentinfo{martinproductions.time_me/martinproductions.time_me.myactivity}: java.lang.nullpointerexception             @ android.app.activitythread.performlaunchactivity(activitythread.java:2195)             @ android.app.activitythread.handlelaunchactivity(activitythread.java:2245)             @ android.app.activitythread.access$800(activitythread.java:135)             @ android.app.activitythread$h.handlemessage(activitythread.java:1196)             @ android.os.handler.dispatchmessage(handler.java:102)             @ android.os.looper.loop(looper.java:136)             @ android.app.activitythread.main(activitythread.java:5017)             @ java.lang.reflect.method.invokenative(native method)             @ java.lang.reflect.method.invoke(method.java:515)             @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:779)             @ com.android.internal.os.zygoteinit.main(zygoteinit.java:595)             @ dalvik.system.nativestart.main(native method)      caused by: java.lang.nullpointerexception             @ martinproductions.time_me.myactivity.oncreate(myactivity.java:49)             @ android.app.activity.performcreate(activity.java:5231)             @ android.app.instrumentation.callactivityoncreate(instrumentation.java:1087)             @ android.app.activitythread.performlaunchactivity(activitythread.java:2159)             at android.app.activitythread.handlelaunchactivity(activitythread.java:2245)             at android.app.activitythread.access$800(activitythread.java:135)             at android.app.activitythread$h.handlemessage(activitythread.java:1196)             at android.os.handler.dispatchmessage(handler.java:102)             at android.os.looper.loop(looper.java:136)             at android.app.activitythread.main(activitythread.java:5017)             at java.lang.reflect.method.invokenative(native method)             at java.lang.reflect.method.invoke(method.java:515)             at com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:779)             at com.android.internal.os.zygoteinit.main(zygoteinit.java:595)             at dalvik.system.nativestart.main(native method) 06-13 19:29:18.550      851-851/martinproductions.time_me i/process﹕ sending signal. pid: 851 sig: 9 device not found 

the updated logcat:

06-13 19:56:50.810      987-987/martinproductions.time_me d/dalvikvm﹕ not late-enabling checkjni (already on) 06-13 19:56:53.550      987-987/martinproductions.time_me d/dalvikvm﹕ gc_for_alloc freed 71k, 10% free 3452k/3812k, paused 36ms, total 38ms 06-13 19:56:53.690      987-987/martinproductions.time_me d/dalvikvm﹕ gc_for_alloc freed 3k, 10% free 3670k/4036k, paused 19ms, total 20ms 06-13 19:56:53.710      987-987/martinproductions.time_me i/dalvikvm-heap﹕ grow heap (frag case) 6.283mb 2536936-byte allocation 06-13 19:56:53.740      987-996/martinproductions.time_me d/dalvikvm﹕ gc_for_alloc freed <1k, 6% free 6148k/6516k, paused 27ms, total 27ms 06-13 19:56:53.890      987-987/martinproductions.time_me d/androidruntime﹕ shutting down vm 06-13 19:56:53.890      987-987/martinproductions.time_me w/dalvikvm﹕ threadid=1: thread exiting uncaught exception (group=0xb1a8fba8) 06-13 19:56:53.900      987-987/martinproductions.time_me e/androidruntime﹕ fatal exception: main     process: martinproductions.time_me, pid: 987     java.lang.runtimeexception: unable start activity componentinfo{martinproductions.time_me/martinproductions.time_me.myactivity}: java.lang.nullpointerexception             @ android.app.activitythread.performlaunchactivity(activitythread.java:2195)             @ android.app.activitythread.handlelaunchactivity(activitythread.java:2245)             @ android.app.activitythread.access$800(activitythread.java:135)             @ android.app.activitythread$h.handlemessage(activitythread.java:1196)             @ android.os.handler.dispatchmessage(handler.java:102)             @ android.os.looper.loop(looper.java:136)             @ android.app.activitythread.main(activitythread.java:5017)             @ java.lang.reflect.method.invokenative(native method)             @ java.lang.reflect.method.invoke(method.java:515)             @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:779)             @ com.android.internal.os.zygoteinit.main(zygoteinit.java:595)             @ dalvik.system.nativestart.main(native method)      caused by: java.lang.nullpointerexception             @ martinproductions.time_me.myactivity.oncreate(myactivity.java:38)             @ android.app.activity.performcreate(activity.java:5231)             @ android.app.instrumentation.callactivityoncreate(instrumentation.java:1087)             @ android.app.activitythread.performlaunchactivity(activitythread.java:2159)             at android.app.activitythread.handlelaunchactivity(activitythread.java:2245)             at android.app.activitythread.access$800(activitythread.java:135)             at android.app.activitythread$h.handlemessage(activitythread.java:1196)             at android.os.handler.dispatchmessage(handler.java:102)             at android.os.looper.loop(looper.java:136)             at android.app.activitythread.main(activitythread.java:5017)             at java.lang.reflect.method.invokenative(native method)             at java.lang.reflect.method.invoke(method.java:515)             at com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:779)             at com.android.internal.os.zygoteinit.main(zygoteinit.java:595)             at dalvik.system.nativestart.main(native method) 06-13 19:56:57.120      987-987/martinproductions.time_me i/process﹕ sending signal. pid: 987 sig: 9 06-13 19:57:03.190    1030-1030/martinproductions.time_me d/dalvikvm﹕ gc_for_alloc freed 79k, 10% free 3452k/3820k, paused 102ms, total 104ms 06-13 19:57:03.520    1030-1030/martinproductions.time_me d/dalvikvm﹕ gc_for_alloc freed 3k, 10% free 3670k/4044k, paused 20ms, total 21ms 06-13 19:57:03.540    1030-1030/martinproductions.time_me i/dalvikvm-heap﹕ grow heap (frag case) 6.283mb 2536936-byte allocation 06-13 19:57:03.580    1030-1039/martinproductions.time_me d/dalvikvm﹕ gc_for_alloc freed <1k, 6% free 6148k/6524k, paused 33ms, total 33ms 06-13 19:57:03.730    1030-1030/martinproductions.time_me d/androidruntime﹕ shutting down vm 06-13 19:57:03.730    1030-1030/martinproductions.time_me w/dalvikvm﹕ threadid=1: thread exiting uncaught exception (group=0xb1a8fba8) 06-13 19:57:03.740    1030-1030/martinproductions.time_me e/androidruntime﹕ fatal exception: main 

as mcount final, can assigned once. can make mcount member of class myactivity, can accessed within onclicklistener without being final.

code should this:

public class myactivity extends activity implements actionbar.tablistener {  sectionspageradapter msectionspageradapter; viewpager mviewpager; double mcount;  @override public void oncreate(bundle savedinstancestate) {     super.oncreate(savedinstancestate);     setcontentview(r.layout.activity_my);     button start;     final textview stopwatch_num;     mcount = 0.0;     start = (button)findviewbyid(r.id.start_button);     stopwatch_num = (textview)findviewbyid(r.id.timer_num);     start.setonclicklistener(new view.onclicklistener() {         @override         public void onclick(view view) {             mcount = mcount + .01;             stopwatch_num.settext(""+mcount);         }       }); 

Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -