android - Unable to instantiate main activity - ClassNotFound -
i cannot open application. far remember, appeared first time when created new class (now deleted). error occurs if delete below //referencje
, part of layout related them. name of class edited, used work after that.
09-12 18:56:25.512: e/androidruntime(616): fatal exception: main 09-12 18:56:25.512: e/androidruntime(616): java.lang.runtimeexception: unable instantiate activity componentinfo{com.example.test2/com.example.test2.activity_main}: java.lang.classnotfoundexception: com.example.test2.activity_main 09-12 18:56:25.512: e/androidruntime(616): @ android.app.activitythread.performlaunchactivity(activitythread.java:1983) 09-12 18:56:25.512: e/androidruntime(616): @ android.app.activitythread.handlelaunchactivity(activitythread.java:2084) 09-12 18:56:25.512: e/androidruntime(616): @ android.app.activitythread.access$600(activitythread.java:130) 09-12 18:56:25.512: e/androidruntime(616): @ android.app.activitythread$h.handlemessage(activitythread.java:1195) 09-12 18:56:25.512: e/androidruntime(616): @ android.os.handler.dispatchmessage(handler.java:99) 09-12 18:56:25.512: e/androidruntime(616): @ android.os.looper.loop(looper.java:137) 09-12 18:56:25.512: e/androidruntime(616): @ android.app.activitythread.main(activitythread.java:4745) 09-12 18:56:25.512: e/androidruntime(616): @ java.lang.reflect.method.invokenative(native method) 09-12 18:56:25.512: e/androidruntime(616): @ java.lang.reflect.method.invoke(method.java:511) 09-12 18:56:25.512: e/androidruntime(616): @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:786) 09-12 18:56:25.512: e/androidruntime(616): @ com.android.internal.os.zygoteinit.main(zygoteinit.java:553) 09-12 18:56:25.512: e/androidruntime(616): @ dalvik.system.nativestart.main(native method) 09-12 18:56:25.512: e/androidruntime(616): caused by: java.lang.classnotfoundexception: com.example.test2.activity_main 09-12 18:56:25.512: e/androidruntime(616): @ dalvik.system.basedexclassloader.findclass(basedexclassloader.java:61) 09-12 18:56:25.512: e/androidruntime(616): @ java.lang.classloader.loadclass(classloader.java:501) 09-12 18:56:25.512: e/androidruntime(616): @ java.lang.classloader.loadclass(classloader.java:461) 09-12 18:56:25.512: e/androidruntime(616): @ android.app.instrumentation.newactivity(instrumentation.java:1053) 09-12 18:56:25.512: e/androidruntime(616): @ android.app.activitythread.performlaunchactivity(activitythread.java:1974) 09-12 18:56:25.512: e/androidruntime(616): ... 11 more
funkcja.java
package com.example.test2; import android.app.actionbar; import android.app.activity; import android.os.build; import android.os.bundle; import android.view.view; import android.view.view.onclicklistener; import android.view.windowmanager; import android.widget.button; import android.widget.edittext; import android.widget.textview; import android.widget.toast; public class funkcja extends activity { textview wynik; button przelicz; edittext wspxa, wspxb, wspya, wspyb; double n1; public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); //referencje wynik = (textview) findviewbyid(r.id.wynik); przelicz = (button) findviewbyid(r.id.przelicz); wspxa = (edittext) findviewbyid(r.id.wspxa); wspya = (edittext) findviewbyid(r.id.wspya); wspxb = (edittext) findviewbyid(r.id.wspxb); wspyb = (edittext) findviewbyid(r.id.wspyb); //hiding status bar if (build.version.sdk_int < 16) { getwindow().setflags(windowmanager.layoutparams.flag_fullscreen, windowmanager.layoutparams.flag_fullscreen); } view decorview = getwindow().getdecorview(); int uioptions = view.system_ui_flag_fullscreen; decorview.setsystemuivisibility(uioptions); actionbar actionbar = getactionbar(); actionbar.hide(); przelicz.setonclicklistener(new onclicklistener(){ public void onclick(view v) { try{ if(wspxa!=null){ double n1 = double.parsedouble(wspxa.gettext().tostring()); if (n1!=0){ string total = double.tostring(n1); wynik.settext(total); } } } catch(exception e){ toast.maketext(getbasecontext(), "bledne dane", toast.length_long).show(); } } }); } }
manifest
<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.test2" android:versioncode="1" android:versionname="1.0" > <uses-sdk android:minsdkversion="16" android:targetsdkversion="16" /> <application android:allowbackup="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/apptheme" > <activity android:name=".activity_main" android:label="@string/app_name" > <intent-filter> <action android:name="android.intent.action.main" /> <category android:name="android.intent.category.launcher" /> </intent-filter> </activity> </application> </manifest>
layout:
<relativelayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" 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="activity_main" > <spinner android:id="@+id/spinner1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_above="@+id/literaa" android:layout_alignleft="@+id/literaa" /> <edittext android:id="@+id/wspya" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_above="@+id/literab" android:layout_torightof="@+id/przelicz" android:ems="10" android:inputtype="numberdecimal" android:width="50dp" /> <edittext android:id="@+id/wspyb" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignbaseline="@+id/wspxb" android:layout_alignbottom="@+id/wspxb" android:layout_alignleft="@+id/wspya" android:ems="10" android:inputtype="numberdecimal" android:width="50dp" /> <textview android:id="@+id/ywynik" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@+id/przelicz" android:layout_marginright="33dp" android:layout_margintop="24dp" android:layout_toleftof="@+id/wynik" android:text="y=" android:textappearance="?android:attr/textappearancelarge" /> <button android:id="@+id/przelicz" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@+id/wspxb" android:layout_centerhorizontal="true" android:layout_margintop="24dp" android:text="przelicz" /> <edittext android:id="@+id/wspxa" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_above="@+id/literab" android:layout_centerhorizontal="true" android:ems="10" android:inputtype="numberdecimal" android:width="50dp" /> <edittext android:id="@+id/wspxb" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignbottom="@+id/literab" android:layout_alignleft="@+id/wspxa" android:ems="10" android:inputtype="numberdecimal" android:width="50dp" > <requestfocus /> </edittext> <textview android:id="@+id/literab" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@+id/literaa" android:layout_marginright="18dp" android:layout_margintop="33dp" android:layout_toleftof="@+id/przelicz" android:text="punkt b:" android:textsize="20sp" /> <textview android:id="@+id/literaa" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignleft="@+id/literab" android:layout_alignparenttop="true" android:layout_margintop="56dp" android:text="punkt a:" android:textsize="20sp" /> <textview android:id="@+id/textview1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_above="@+id/wspxa" android:layout_centerhorizontal="true" android:layout_marginbottom="14dp" android:text="x" android:textsize="22sp" /> <textview android:id="@+id/textview01" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignbaseline="@+id/textview1" android:layout_alignbottom="@+id/textview1" android:layout_alignleft="@+id/wspya" android:layout_marginleft="16dp" android:text="y" android:textsize="22sp" /> <textview android:id="@+id/wynik" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignbottom="@+id/ywynik" android:layout_alignright="@+id/wspyb" android:layout_aligntop="@+id/ywynik" android:layout_torightof="@+id/literaa" android:textappearance="?android:attr/textappearancelarge" /> </relativelayout>
your manifest has activity_main
activity's java class name. change funkcja
, actual java class name activity.
Comments
Post a Comment