android - App stops working -
i totally new in android , main activity. encounter error in every project:
import android.os.bundle; import android.app.activity; import android.view.menu; import android.view.view.onclicklistener; import android.widget.button; import android.widget.edittext; public class mainactivity extends activity { button btnone,btntwo,btnthree,btnfour,btnfive,btnsix,btnseven,btneight,btnnine,btnzeo,btnstar,btnhash,btndial,btnbackspace; edittext etnum; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); btnone = (button)findviewbyid(r.id.btnone); btntwo = (button)findviewbyid(r.id.btntwo); btnthree = (button)findviewbyid(r.id.btnthree); btnfour = (button)findviewbyid(r.id.btfour); btnfive = (button)findviewbyid(r.id.btnfive); btnsix = (button)findviewbyid(r.id.btnsix); btnseven = (button)findviewbyid(r.id.btnseven); btneight = (button)findviewbyid(r.id.btneight); btnnine = (button)findviewbyid(r.id.btnnine); btnzeo = (button)findviewbyid(r.id.btnzero); btnstar = (button)findviewbyid(r.id.btnstar); btnhash = (button)findviewbyid(r.id.btnhash); btndial = (button)findviewbyid(r.id.btncall); btnbackspace = (button)findviewbyid(r.id.btnbacspace); etnum = (edittext) findviewbyid(r.id.etnumbr); btnone.setonclicklistener((onclicklistener)this); btntwo.setonclicklistener((onclicklistener)this); btnthree.setonclicklistener((onclicklistener)this); btnfour.setonclicklistener((onclicklistener)this); btnfive.setonclicklistener((onclicklistener)this); btnsix.setonclicklistener((onclicklistener)this); btnseven.setonclicklistener((onclicklistener)this); btneight.setonclicklistener((onclicklistener)this); btnnine.setonclicklistener((onclicklistener)this); btnzeo.setonclicklistener((onclicklistener)this); btnstar.setonclicklistener((onclicklistener)this); btnhash.setonclicklistener((onclicklistener)this); btndial.setonclicklistener((onclicklistener)this); btnbackspace.setonclicklistener((onclicklistener)this); etnum.setonclicklistener((onclicklistener)this); } @override public boolean oncreateoptionsmenu(menu menu) { // inflate menu; adds items action bar if present. getmenuinflater().inflate(r.menu.main, menu); return true; } }
this logcat logs, encounter error in every project:
05-01 23:18:40.364: e/androidruntime(5668): fatal exception: main 05-01 23:18:40.364: e/androidruntime(5668): java.lang.runtimeexception: unable instantiate activity componentinfo{com.casbwp.mydialerapp/com.casbwp.mydialerapp.mainactivity}: java.lang.classnotfoundexception: didn't find class "com.casbwp.mydialerapp.mainactivity" on path: /data/app/com.casbwp.mydialerapp-1.apk 05-01 23:18:40.364: e/androidruntime(5668): @ android.app.activitythread.performlaunchactivity(activitythread.java:2106) 05-01 23:18:40.364: e/androidruntime(5668): @ android.app.activitythread.handlelaunchactivity(activitythread.java:2230) 05-01 23:18:40.364: e/androidruntime(5668): @ android.app.activitythread.access$600(activitythread.java:141) 05-01 23:18:40.364: e/androidruntime(5668): @ android.app.activitythread$h.handlemessage(activitythread.java:1234) 05-01 23:18:40.364: e/androidruntime(5668): @ android.os.handler.dispatchmessage(handler.java:99) 05-01 23:18:40.364: e/androidruntime(5668): @ android.os.looper.loop(looper.java:137) 05-01 23:18:40.364: e/androidruntime(5668): @ android.app.activitythread.main(activitythread.java:5039) 05-01 23:18:40.364: e/androidruntime(5668): @ java.lang.reflect.method.invokenative(native method) 05-01 23:18:40.364: e/androidruntime(5668): @ java.lang.reflect.method.invoke(method.java:511) 05-01 23:18:40.364: e/androidruntime(5668): @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:793) 05-01 23:18:40.364: e/androidruntime(5668): @ com.android.internal.os.zygoteinit.main(zygoteinit.java:560) 05-01 23:18:40.364: e/androidruntime(5668): @ dalvik.system.nativestart.main(native method) 05-01 23:18:40.364: e/androidruntime(5668): caused by: java.lang.classnotfoundexception: didn't find class "com.casbwp.mydialerapp.mainactivity" on path: /data/app/com.casbwp.mydialerapp-1.apk 05-01 23:18:40.364: e/androidruntime(5668): @ dalvik.system.basedexclassloader.findclass(basedexclassloader.java:65) 05-01 23:18:40.364: e/androidruntime(5668): @ java.lang.classloader.loadclass(classloader.java:501) 05-01 23:18:40.364: e/androidruntime(5668): @ java.lang.classloader.loadclass(classloader.java:461) 05-01 23:18:40.364: e/androidruntime(5668): @ android.app.instrumentation.newactivity(instrumentation.java:1054) 05-01 23:18:40.364: e/androidruntime(5668): @ android.app.activitythread.performlaunchactivity(activitythread.java:2097) 05-01 23:18:40.364: e/androidruntime(5668): ... 11 more
this xml file:
<tablelayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/tablelayout1" android:layout_width="match_parent" android:layout_height="match_parent" android:minheight="30dp" android:minwidth="50dp" android:nextfocusdown="@string/btn0" android:paddingbottom="@dimen/activity_vertical_margin" android:paddingleft="@dimen/activity_horizontal_margin" android:paddingright="@dimen/activity_horizontal_margin" android:paddingtop="@dimen/activity_vertical_margin" tools:context=".mainactivity" > <tablerow android:id="@+id/tblrow" android:layout_width="wrap_content" android:layout_height="wrap_content" > <linearlayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="horizontal" > <edittext android:id="@+id/etnumbr" android:layout_width="match_parent" android:layout_height="wrap_content" android:ems="10" android:inputtype="number" > <requestfocus /> </edittext> </linearlayout> </tablerow> <android.support.v7.widget.space android:id="@+id/space1" android:layout_width="wrap_content" android:layout_height="wrap_content" /> <tablerow android:id="@+id/tblrow2" android:layout_width="wrap_content" android:layout_height="wrap_content" > </tablerow> <tablerow android:id="@+id/tablerow4" android:layout_width="wrap_content" android:layout_height="wrap_content" > <linearlayout android:layout_width="wrap_content" android:layout_height="wrap_content" > <button android:id="@+id/btnone" android:layout_width="95dp" android:layout_height="80dp" android:text="@string/btn1" /> <button android:id="@+id/btntwo" android:layout_width="95dp" android:layout_height="80dp" android:text="@string/btn2" /> <button android:id="@+id/btnthree" android:layout_width="95dp" android:layout_height="80dp" android:text="@string/btn3" /> </linearlayout> </tablerow> <tablerow android:id="@+id/tablerow6" android:layout_width="wrap_content" android:layout_height="wrap_content" > <linearlayout android:layout_width="wrap_content" android:layout_height="wrap_content" > <button android:id="@+id/btfour" android:layout_width="95dp" android:layout_height="80dp" android:text="@string/btn4" /> <button android:id="@+id/btnfive" android:layout_width="95dp" android:layout_height="80dp" android:text="@string/btn5" /> <button android:id="@+id/btnsix" android:layout_width="95dp" android:layout_height="80dp" android:text="@string/btn6" /> </linearlayout> </tablerow> <tablerow android:id="@+id/tablerow5" android:layout_width="wrap_content" android:layout_height="wrap_content" > <linearlayout android:layout_width="wrap_content" android:layout_height="wrap_content" > <button android:id="@+id/btnseven" android:layout_width="95dp" android:layout_height="80dp" android:text="@string/btn7" /> <button android:id="@+id/btneight" android:layout_width="95dp" android:layout_height="80dp" android:text="@string/btn8" /> <button android:id="@+id/btnnine" android:layout_width="95dp" android:layout_height="80dp" android:text="@string/btn9" /> </linearlayout> </tablerow> <tablerow android:id="@+id/tablerow1" android:layout_width="wrap_content" android:layout_height="wrap_content" > <linearlayout android:layout_width="wrap_content" android:layout_height="wrap_content" > <button android:id="@+id/btnstar" android:layout_width="95dp" android:layout_height="80dp" android:text="@string/btnstar" /> <button android:id="@+id/btnzero" android:layout_width="95dp" android:layout_height="80dp" android:text="@string/btn0" /> <button android:id="@+id/btnhash" android:layout_width="95dp" android:layout_height="80dp" android:text="@string/btnhash" /> </linearlayout> </tablerow> <tablerow android:id="@+id/tablerow2" android:layout_width="wrap_content" android:layout_height="wrap_content" > <linearlayout android:layout_width="wrap_content" android:layout_height="wrap_content" > <button android:id="@+id/btncall" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="0.44" android:background="@drawable/ic_action_call" android:text="@string/btndial" /> <button android:id="@+id/btnbacspace" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="0.45" android:background="@drawable/ic_action_delete" android:text="@string/btnbackspace" /> </linearlayout> </tablerow> </tablelayout>
05-01 23:18:40.364: e/androidruntime(5668): java.lang.runtimeexception: unable instantiate activity componentinfo{com.casbwp.mydialerapp/com.casbwp.mydialerapp.mainactivity}: java.lang.classnotfoundexception: didn't find class "com.casbwp.mydialerapp.mainactivity" on path: /data/app/com.casbwp.mydialerapp-1.apk
you have declare activity inside android manifest.
Comments
Post a Comment