android - "Unfortunately the application (name) has stopped" message -
whenever run app (explore ca) getting message "unfortunately explore ca has stopped". app displays list of tours , gives option filter clicking on menu bar (fancy/cheap/all)
i found solution:
first step: right click on project -> java -> built path ->source ->add folder -> click gen , src ->click ok
second step: right click on project -> go properties -> libraries -> add jars -> , add jars of project libs folder
mainactivity:
package com.exploreca.tourfinder; import java.util.list; import android.app.listactivity; import android.content.intent; import android.content.sharedpreferences; import android.content.sharedpreferences.onsharedpreferencechangelistener; import android.os.bundle; import android.preference.preferencemanager; import android.util.log; import android.view.menu; import android.view.menuitem; import android.view.view; import android.widget.arrayadapter; import com.exploreca.tourfinder.db.toursdatasource; import com.exploreca.tourfinder.model.tour; import com.exploreca.tourfinder.xml.tourspullparser; public class mainactivity extends listactivity { public static final string logtag="exploreca"; public static final string username="pref_username"; public static final string viewimage="pref_viewimages"; private sharedpreferences settings; private onsharedpreferencechangelistener listener; private list<tour> tours; toursdatasource datasource; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); settings = preferencemanager.getdefaultsharedpreferences(this); listener = new onsharedpreferencechangelistener() { @override public void onsharedpreferencechanged(sharedpreferences sharedpreferences, string key) { mainactivity.this.refreshdisplay(); } }; settings.registeronsharedpreferencechangelistener(listener); datasource = new toursdatasource(this); datasource.open(); tours = datasource.findall(); if (tours.size() == 0) { createdata(); tours = datasource.findall(); } refreshdisplay(); } @override public boolean oncreateoptionsmenu(menu menu) { // inflate menu; adds items action bar if present. getmenuinflater().inflate(r.menu.activity_main, menu); return true; } @override public boolean onoptionsitemselected(menuitem item) { switch (item.getitemid()) { case r.id.menu_all: tours = datasource.findall(); refreshdisplay(); break; case r.id.menu_cheap: tours = datasource.findfiltered("price <= 300", "price asc"); refreshdisplay(); break; case r.id.menu_fancy: tours = datasource.findfiltered("price >= 1000", "price desc"); refreshdisplay(); break; default: break; } return super.onoptionsitemselected(item); } public void setpreference(view v) { log.i(logtag, "clicked set"); intent intent = new intent(this, settingsactivity.class); startactivity(intent); } public void refreshdisplay() { arrayadapter<tour> adapter = new arrayadapter<tour>(this, android.r.layout.simple_list_item_1, tours); setlistadapter(adapter); } @override protected void onresume() { super.onresume(); datasource.open(); } @override protected void onpause() { super.onpause(); datasource.close(); } private void createdata() { tourspullparser parser = new tourspullparser(); list<tour> tours = parser.parsexml(this); (tour tour : tours) { datasource.create(tour); } } }
logcat:
06-04 08:39:51.231: d/androidruntime(26469): shutting down vm 06-04 08:39:51.231: w/dalvikvm(26469): threadid=1: thread exiting uncaught exception (group=0x40ff4930) 06-04 08:39:51.231: e/androidruntime(26469): fatal exception: main 06-04 08:39:51.231: e/androidruntime(26469): java.lang.runtimeexception: unable instantiate activity componentinfo{com.exploreca.tourfinder/com.exploreca.tourfinder.mainactivity}: java.lang.classnotfoundexception: didn't find class "com.exploreca.tourfinder.mainactivity" on path: /data/app/com.exploreca.tourfinder-1.apk 06-04 08:39:51.231: e/androidruntime(26469): @ android.app.activitythread.performlaunchactivity(activitythread.java:2172) 06-04 08:39:51.231: e/androidruntime(26469): @ android.app.activitythread.handlelaunchactivity(activitythread.java:2296) 06-04 08:39:51.231: e/androidruntime(26469): @ android.app.activitythread.access$700(activitythread.java:151) 06-04 08:39:51.231: e/androidruntime(26469): @ android.app.activitythread$h.handlemessage(activitythread.java:1281) 06-04 08:39:51.231: e/androidruntime(26469): @ android.os.handler.dispatchmessage(handler.java:99) 06-04 08:39:51.231: e/androidruntime(26469): @ android.os.looper.loop(looper.java:137) 06-04 08:39:51.231: e/androidruntime(26469): @ android.app.activitythread.main(activitythread.java:5293) 06-04 08:39:51.231: e/androidruntime(26469): @ java.lang.reflect.method.invokenative(native method) 06-04 08:39:51.231: e/androidruntime(26469): @ java.lang.reflect.method.invoke(method.java:511) 06-04 08:39:51.231: e/androidruntime(26469): @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:1102) 06-04 08:39:51.231: e/androidruntime(26469): @ com.android.internal.os.zygoteinit.main(zygoteinit.java:869) 06-04 08:39:51.231: e/androidruntime(26469): @ dalvik.system.nativestart.main(native method) 06-04 08:39:51.231: e/androidruntime(26469): caused by: java.lang.classnotfoundexception: didn't find class "com.exploreca.tourfinder.mainactivity" on path: /data/app/com.exploreca.tourfinder-1.apk 06-04 08:39:51.231: e/androidruntime(26469): @ dalvik.system.basedexclassloader.findclass(basedexclassloader.java:65) 06-04 08:39:51.231: e/androidruntime(26469): @ java.lang.classloader.loadclass(classloader.java:501) 06-04 08:39:51.231: e/androidruntime(26469): @ java.lang.classloader.loadclass(classloader.java:461) 06-04 08:39:51.231: e/androidruntime(26469): @ android.app.instrumentation.newactivity(instrumentation.java:1071) 06-04 08:39:51.231: e/androidruntime(26469): @ android.app.activitythread.performlaunchactivity(activitythread.java:2163) 06-04 08:39:51.231: e/androidruntime(26469): ... 11 more
manifest
<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.exploreca.tourfinder" android:versioncode="1" android:versionname="1.0" > <uses-sdk android:minsdkversion="8" android:targetsdkversion="17" /> <uses-permission android:name="android.permission.write_external_storage"/> <application android:allowbackup="true" android:icon="@drawable/ic_exploreca" android:label="@string/app_name" android:theme="@style/apptheme" > <activity android:name="com.exploreca.tourfinder.mainactivity" 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>
Comments
Post a Comment