i have coded project in androidstudio version 1.5 , after time coded same project version 2.1.2 (mostly copy pasted java methods old project) , showing me fatal exception 16 errors should rid of these errors. following exceptions.
fatal exception: main java.lang.runtimeexception: unable instantiate activity componentinfo{com.example.imtiaz.recognizer/com.example.imtiaz.recognizer.mainactivity}:java.lang.nullpointerexception @ android.app.activitythread.performlaunchactivity(activitythread.java:2232) @ android.app.activitythread.handlelaunchactivity(activitythread.java:2362) @ android.app.activitythread.access$700(activitythread.java:168) @ android.app.activitythread$h.handlemessage(activitythread.java:1329) @ android.os.handler.dispatchmessage(handler.java:99) @ android.os.looper.loop(looper.java:177) @ android.app.activitythread.main(activitythread.java:5493) @ java.lang.reflect.method.invokenative(native method) @ java.lang.reflect.method.invoke(method.java:525) @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:1225) @ com.android.internal.os.zygoteinit.main(zygoteinit.java:1041) @ dalvik.system.nativestart.main(native method) caused by: java.lang.nullpointerexception @ android.support.v7.app.appcompatdelegateimplbase.<init>(appcompatdelegateimplbase.java:116) @ android.support.v7.app.appcompatdelegateimplv9.<init>(appcompatdelegateimplv9.java:147) @ android.support.v7.app.appcompatdelegateimplv11.<init>(appcompatdelegateimplv11.java:27) @ android.support.v7.app.appcompatdelegateimplv14.<init>(appcompatdelegateimplv14.java:50) @ android.support.v7.app.appcompatdelegate.create(appcompatdelegate.java:201) @ android.support.v7.app.appcompatdelegate.create(appcompatdelegate.java:181) @ android.support.v7.app.appcompatactivity.getdelegate(appcompatactivity.java:521) @ android.support.v7.app.appcompatactivity.findviewbyid(appcompatactivity.java:190) @ java.lang.class.newinstanceimpl(native method) @ java.lang.class.newinstance(class.java:1130) @ android.app.instrumentation.newactivity(instrumentation.java:1078) @ android.app.activitythread.performlaunchactivity(activitythread.java:2223) @ android.app.activitythread.handlelaunchactivity(activitythread.java:2362) @ android.app.activitythread.access$700(activitythread.java:168) @ android.app.activitythread$h.handlemessage(activitythread.java:1329) @ android.os.handler.dispatchmessage(handler.java:99) @ android.os.looper.loop(looper.java:177) @ android.app.activitythread.main(activitythread.java:5493) @ java.lang.reflect.method.invokenative(native method) @ java.lang.reflect.method.invoke(method.java:525) @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:1225) @ com.android.internal.os.zygoteinit.main(zygoteinit.java:1041) @ dalvik.system.nativestart.main(native method)
... @ android.support.v7.app.appcompatactivity.findviewbyid(appcompatactivity.java:190) @ com.example.imtiaz.recognizer.mainactivity.<init>(mainactivity.java:26) ...
it appears call findviewbyid()
in constructor of activity
subclass. cannot this. must initialization in oncreate()
method instead. suggest learn activity lifecycle. must use correctly in order write android apps.
Comments
Post a Comment