FATAL EXCEPTION: main - android

I am developing in app where I am using an activity in which I'm displaying a list view items page by page by using threading, When the user selects the item it will take the user to another activity.
But Here some times when I click on list view item the app crashes. It says something in log cat but I am unable to understand it.
Here is the Stack Trace:
06-24 16:26:44.320: ERROR/AndroidRuntime(4248): FATAL EXCEPTION: main
06-24 16:26:44.320: ERROR/AndroidRuntime(4248): android.view.WindowManager$BadTokenException: Unable to add window -- token android.os.BinderProxy#4073ef78 is not valid; is your activity running?
06-24 16:26:44.320: ERROR/AndroidRuntime(4248): at android.view.ViewRoot.setView(ViewRoot.java:527)
06-24 16:26:44.320: ERROR/AndroidRuntime(4248): at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:177)
06-24 16:26:44.320: ERROR/AndroidRuntime(4248): at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:91)
06-24 16:26:44.320: ERROR/AndroidRuntime(4248): at android.view.Window$LocalWindowManager.addView(Window.java:424)
06-24 16:26:44.320: ERROR/AndroidRuntime(4248): at android.app.Dialog.show(Dialog.java:241)
06-24 16:26:44.320: ERROR/AndroidRuntime(4248): at android.app.AlertDialog$Builder.show(AlertDialog.java:802)
06-24 16:26:44.320: ERROR/AndroidRuntime(4248): at com.usablenet.mobile.walgreen.app.util.ErrorAlertServiceImp.showErrorAlert(ErrorAlertServiceImp.java:86)
06-24 16:26:44.320: ERROR/AndroidRuntime(4248): at com.usablenet.mobile.walgreen.pharmacy.PrescriptionList.showErrorCodeAlert(PrescriptionList.java:360)
06-24 16:26:44.320: ERROR/AndroidRuntime(4248): at com.usablenet.mobile.walgreen.pharmacy.PrescriptionList.access$300(PrescriptionList.java:45)
06-24 16:26:44.320: ERROR/AndroidRuntime(4248): at com.usablenet.mobile.walgreen.pharmacy.PrescriptionList$2.handleMessage(PrescriptionList.java:323)
06-24 16:26:44.320: ERROR/AndroidRuntime(4248): at android.os.Handler.dispatchMessage(Handler.java:99)
06-24 16:26:44.320: ERROR/AndroidRuntime(4248): at android.os.Looper.loop(Looper.java:130)
06-24 16:26:44.320: ERROR/AndroidRuntime(4248): at android.app.ActivityThread.main(ActivityThread.java:3683)
06-24 16:26:44.320: ERROR/AndroidRuntime(4248): at java.lang.reflect.Method.invokeNative(Native Method)
06-24 16:26:44.320: ERROR/AndroidRuntime(4248): at java.lang.reflect.Method.invoke(Method.java:507)
06-24 16:26:44.320: ERROR/AndroidRuntime(4248): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
06-24 16:26:44.320: ERROR/AndroidRuntime(4248): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
06-24 16:26:44.320: ERROR/AndroidRuntime(4248): at dalvik.system.NativeStart.main(Native Method)
Thanks,
Balu.

Use getApplicationContext for the AlertDialog, otherwise you will get this error when you switch between tasks.
Instead of: AlertDialog.Builder builder = new AlertDialog.Builder(this);
Use:ConnectionDetector = new ConnectionDetector(getApplicationContext());
The same goes for any listeners on the dialog.
Furthermore:
if (!ConnectionDetector.isConnectingToInternet()) {
alert.showAlertDialog(ListActivity.this, "Internet Connection Error","Please connect to working Internet connection", false);
// stop executing code by return
return;
}

Related

android map application is not running on emulator

I have developed a Android Map Application in Android and Want to Launch It On Google Play.
Problem is that when I Try to Run it On Emulator It Shows this Error in Console
[2013-06-24 10:14:18 - Track] Installation error: INSTALL_FAILED_MISSING_SHARED_LIBRARY
[2013-06-24 10:14:18 - Track] Please check logcat output for more details.
[2013-06-24 10:14:18 - Track] Launch canceled!
Please Any One Help Me To Test it On Emulator and Tell me What Exactly I am Missing or Is There any other problem in it.Thanks in Advance
Update
Log Cat
06-24 14:43:12.462: D/dalvikvm(380): GC_CONCURRENT freed 376K, 48% free 3039K/5831K, external 716K/1038K, paused 5ms+5ms
06-24 14:43:16.303: D/dalvikvm(380): GC_CONCURRENT freed 578K, 50% free 3020K/6023K, external 716K/1038K, paused 5ms+49ms
06-24 14:43:16.863: D/dalvikvm(380): GC_CONCURRENT freed 298K, 47% free 3234K/6023K, external 716K/1038K, paused 5ms+7ms
06-24 14:43:17.193: D/dalvikvm(380): GC_CONCURRENT freed 468K, 47% free 3318K/6215K, external 716K/1038K, paused 5ms+32ms
06-24 14:43:17.643: D/dalvikvm(380): GC_CONCURRENT freed 432K, 46% free 3417K/6279K, external 717K/1038K, paused 5ms+6ms
06-24 14:43:37.943: E/log_tag(380): Error in http connectionjava.net.UnknownHostException: sml.com.pk
06-24 14:43:37.943: E/log_tag(380): Error converting result java.lang.NullPointerException
06-24 14:43:37.963: D/AndroidRuntime(380): Shutting down VM
06-24 14:43:37.974: W/dalvikvm(380): threadid=1: thread exiting with uncaught exception (group=0x40015560)
06-24 14:43:37.982: E/AndroidRuntime(380): FATAL EXCEPTION: main
06-24 14:43:37.982: E/AndroidRuntime(380): java.lang.RuntimeException: Unable to start activity ComponentInfo{map2.pkg.pkg/map2.pkg.pkg.GMapsActivity}: java.lang.NullPointerException
06-24 14:43:37.982: E/AndroidRuntime(380): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1647)
06-24 14:43:37.982: E/AndroidRuntime(380): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
06-24 14:43:37.982: E/AndroidRuntime(380): at android.app.ActivityThread.access$1500(ActivityThread.java:117)
06-24 14:43:37.982: E/AndroidRuntime(380): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
06-24 14:43:37.982: E/AndroidRuntime(380): at android.os.Handler.dispatchMessage(Handler.java:99)
06-24 14:43:37.982: E/AndroidRuntime(380): at android.os.Looper.loop(Looper.java:130)
06-24 14:43:37.982: E/AndroidRuntime(380): at android.app.ActivityThread.main(ActivityThread.java:3683)
06-24 14:43:37.982: E/AndroidRuntime(380): at java.lang.reflect.Method.invokeNative(Native Method)
06-24 14:43:37.982: E/AndroidRuntime(380): at java.lang.reflect.Method.invoke(Method.java:507)
06-24 14:43:37.982: E/AndroidRuntime(380): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
06-24 14:43:37.982: E/AndroidRuntime(380): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
06-24 14:43:37.982: E/AndroidRuntime(380): at dalvik.system.NativeStart.main(Native Method)
06-24 14:43:37.982: E/AndroidRuntime(380): Caused by: java.lang.NullPointerException
06-24 14:43:37.982: E/AndroidRuntime(380): at org.json.JSONTokener.nextCleanInternal(JSONTokener.java:112)
06-24 14:43:37.982: E/AndroidRuntime(380): at org.json.JSONTokener.nextValue(JSONTokener.java:90)
06-24 14:43:37.982: E/AndroidRuntime(380): at org.json.JSONArray.<init>(JSONArray.java:87)
06-24 14:43:37.982: E/AndroidRuntime(380): at org.json.JSONArray.<init>(JSONArray.java:103)
06-24 14:43:37.982: E/AndroidRuntime(380): at map2.pkg.pkg.GMapsActivity.onCreate(GMapsActivity.java:112)
06-24 14:43:37.982: E/AndroidRuntime(380): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
06-24 14:43:37.982: E/AndroidRuntime(380): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
06-24 14:43:37.982: E/AndroidRuntime(380): ... 11 more
06-24 14:44:28.792: I/Process(380): Sending signal. PID: 380 SIG: 9
Sir I Have Created Emulator as Google Inc But Now Again m getting Error Above Log Cat/
1) Install Google map APIs. This can be done in Eclispe
Windows/Android SDK and AVD Manager -> Available Packages -> Third
Party Add-ons -> Google Inc. -> Google APIs by Google Inc., Android
API X
2) From command line create new AVD. This can be done by listing
targets (android list targets), then android create avd -n
new_avd_api_233 -t "Google Inc.:Google APIs:X"
3) Then create AVD in Eclipse Windows/Android SDK and AVD Manager ->
New... -> (Name: new_avd_X, Target: Google APIs (Google Inc.) - API
Level X)
4) Create Android Project in Eclipse File/New/Android Project and
select Google APIs Build Target.
5) add between
tags.
5) Run Project as Android Application.
If you’re installing an apk into the Android Emulator and seeing this
error (INSTALL_FAILED_MISSING_SHARED_LIBRARY), it may mean that the
app relies on the Google APIs (e.g. for Google Maps and the other
Google Android apps) and your AVD that you’re running was created
without the Google APIs.
Create a new AVD from the AVD Manager using the one of the Google API
targets at the API level that you need and you should be good to go.

ProGuard, How can I hide all logs while obfuscating the code and not break my app?

I have an app that I am trying to clean and protect with ProGuard, I want to Obfuscate to protected from Reverse engineering, I know that It can still be Decompiled but harder to read, I also want to remove all logs from log cat because there are many logs that are sensitive in private information and I don't want anyone to read that. So I have done something but It destroys my app's functionality completely. How can I make it work?
Here is my code
-dontoptimize
-assumenosideeffects class android.util.Log {
public static *** d(...);
public static *** v(...);
public static *** i(...);
}
-libraryjars /myexta.jar
-libraryjars /commons-codec-1.8.jar
-libraryjars /lib.jar
-keep public class com.thejs.app.** {
public protected *;
}
-keep public class com.my.load.** {
public protected *;
}
I have Libraries that I use, How can ProGuard keep all and clean it? When I launch the app the Main activity works, all subactivities crash and don't work.
As I have deeply analyzed the logs It appears that proguard actually breaks all libraries and most classes, The app just can't find it. When I export it without ProGuard it's perfect and there are no issues. What I want to do is two things
1.Obfuscate
2.Remove Entire App's Logging from the log cat.
I am getting stuck in here,I use
-assumenosideeffects class android.util.Log {
public static *** d(...);
public static *** v(...);
public static *** i(...);
}
to delete logs,
Somehow I have never got it to work It always breaks my app, I only need this two things. Shrink is useless and problematic since My app is really small. How can I get it to work?
more info:
Logcat
06-24 14:49:58.750: E/WindowManager(1798): Activity com.thejs.app.Myactivity has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView#309d2738 that was originally added here
06-24 14:49:58.270: E/MP3AudioPlayer(1798): Native libs libffmpeg.so not exists!
06-24 14:49:58.540: E/MP3AudioPlayer(1798): Native libs libffmpeg.so not exists!
06-24 14:49:58.750: E/WindowManager(1798): at android.view.ViewRoot.<init>(ViewRoot.java:259)
06-24 14:49:58.750: E/WindowManager(1798): at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:148)
06-24 14:49:58.750: E/WindowManager(1798): at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:91)
06-24 14:49:58.750: E/WindowManager(1798): at com.thejs.app.Myactivity.onPreExecute(Unknown Source)
06-24 14:49:58.750: E/WindowManager(1798): at android.os.AsyncTask.execute(AsyncTask.java:391)
06-24 14:49:58.750: E/WindowManager(1798): at com.thejs.app.Myactivity.onCreate(Unknown Source)
06-24 14:49:58.750: E/WindowManager(1798): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
06-24 14:49:58.750: E/WindowManager(1798): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
06-24 14:49:58.750: E/WindowManager(1798): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
06-24 14:49:58.750: E/WindowManager(1798): at android.app.ActivityThread.access$1500(ActivityThread.java:117)
06-24 14:49:58.750: E/WindowManager(1798): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
06-24 14:49:58.750: E/WindowManager(1798): at android.os.Handler.dispatchMessage(Handler.java:99)
06-24 14:49:58.750: E/WindowManager(1798): at android.os.Looper.loop(Looper.java:130)
06-24 14:49:58.750: E/WindowManager(1798): at android.app.ActivityThread.main(ActivityThread.java:3683)
06-24 14:49:58.750: E/WindowManager(1798): at java.lang.reflect.Method.invokeNative(Native Method)
06-24 14:49:58.750: E/WindowManager(1798): at java.lang.reflect.Method.invoke(Method.java:507)
06-24 14:49:58.750: E/WindowManager(1798): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:880)
06-24 14:49:58.750: E/WindowManager(1798): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:638)
06-24 14:49:58.750: E/WindowManager(1798): at dalvik.system.NativeStart.main(Native Method)
06-24 14:50:06.070: E/dalvikvm(1798): Class lookup Ljava/lang/NoSuchMethodError; attempted while exception Ljava/lang/NoSuchMethodError; pending
06-24 14:50:06.080: E/dalvikvm(1798): VM aborting
06-24 14:50:06.360: E/dalvikvm(491): Killing existing arm process with pid 1798

IBM Worklight v6.0 - Android AppCenter app unable to launch in Android Emulator

IBM Worklight v6.0
Using the Worklight Liberty Profile Standalone server with Derby database
Following the infocenter instruction to create the app center apk package.
I have tried to use the installer and also Run As Android Application in the Android emulator. The application fails to start with this error in the emulator "Unfortunately, IBM App Center has stopped".
And the following errors are shown in LogCat.
06-24 00:34:56.640: E/AndroidRuntime(999): FATAL EXCEPTION: main
06-24 00:34:56.640: E/AndroidRuntime(999): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.ibm.appcenter/com.ibm.appcenter.AppCenter}: java.lang.UnsupportedOperationException: Device does not have package com.google.android.gsf
06-24 00:34:56.640: E/AndroidRuntime(999): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2059)
06-24 00:34:56.640: E/AndroidRuntime(999): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
06-24 00:34:56.640: E/AndroidRuntime(999): at android.app.ActivityThread.access$600(ActivityThread.java:130)
06-24 00:34:56.640: E/AndroidRuntime(999): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
06-24 00:34:56.640: E/AndroidRuntime(999): at android.os.Handler.dispatchMessage(Handler.java:99)
06-24 00:34:56.640: E/AndroidRuntime(999): at android.os.Looper.loop(Looper.java:137)
06-24 00:34:56.640: E/AndroidRuntime(999): at android.app.ActivityThread.main(ActivityThread.java:4745)
06-24 00:34:56.640: E/AndroidRuntime(999): at java.lang.reflect.Method.invokeNative(Native Method)
06-24 00:34:56.640: E/AndroidRuntime(999): at java.lang.reflect.Method.invoke(Method.java:511)
06-24 00:34:56.640: E/AndroidRuntime(999): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
06-24 00:34:56.640: E/AndroidRuntime(999): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
06-24 00:34:56.640: E/AndroidRuntime(999): at dalvik.system.NativeStart.main(Native Method)
06-24 00:34:56.640: E/AndroidRuntime(999): Caused by: java.lang.UnsupportedOperationException: Device does not have package com.google.android.gsf
06-24 00:34:56.640: E/AndroidRuntime(999): at com.google.android.gcm.GCMRegistrar.checkDevice(GCMRegistrar.java:96)
06-24 00:34:56.640: E/AndroidRuntime(999): at com.ibm.mobile.application.main.AbstractAppCenter.onCreate(AbstractAppCenter.java:66)
06-24 00:34:56.640: E/AndroidRuntime(999): at com.ibm.appcenter.AppCenter.onCreate(AppCenter.java:30)
06-24 00:34:56.640: E/AndroidRuntime(999): at android.app.Activity.performCreate(Activity.java:5008)
06-24 00:34:56.640: E/AndroidRuntime(999): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079)
06-24 00:34:56.640: E/AndroidRuntime(999): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2023)
06-24 00:34:56.640: E/AndroidRuntime(999): ... 11 more
Please see a possible solution here: com.google.android.gsf package couldn't be found
Seems to be related to not using the correct settings for the Android emulator.
I changed the emulator's Target from "Android 4.1.2" to "Google APIs (Google Inc) - API 16". Restart the emulator. The AppCenter can start.
However, I got the error on CordovaWebView: TIMEOUT ERROR! which can be solved by this post -
Giving Time out error while opening worklight hybrid app in android emulator
I can across the same problem running the IBM App Center client app on an Intel x86 based emulator, and had to switch to using one with Google APIs, or a device, say Nexus 7. A quick Google search turned up the following post, which mentions that not all devices include the Google APIs (e.g. Amazon Kindle), so this App Center problem could still exist for some users. The post also has a recommendation to catch the exception:
http://www.marvinlabs.com/2013/01/22/avoiding-crashes-when-using-gcm-in-your-android-application/

Android First Application tutorial

I have created a app based on the android tutorial : http://developer.android.com/training/basics/firstapp/index.html
The code is exactly the same except the app name but the application is force closing.
06-24 16:19:22.279: E/Zygote(33): setreuid() failed. errno: 2
06-24 16:19:33.028: E/Zygote(33): setreuid() failed. errno: 17
06-24 16:19:34.568: E/BatteryService(62): usbOnlinePath not found
06-24 16:19:34.568: E/BatteryService(62): batteryVoltagePath not found
06-24 16:19:34.568: E/BatteryService(62): batteryTemperaturePath not found
06-24 16:19:34.588: E/SurfaceFlinger(62): Couldn't open /sys/power/wait_for_fb_sleep or /sys/power/wait_for_fb_wake
06-24 16:19:34.698: E/SensorService(62): couldn't open device for module sensors (Invalid argument)
06-24 16:19:39.449: E/System(62): Failure starting core service
06-24 16:19:39.449: E/System(62): java.lang.SecurityException
06-24 16:19:39.449: E/System(62): at android.os.BinderProxy.transact(Native Method)
06-24 16:19:39.449: E/System(62): at android.os.ServiceManagerProxy.addService(ServiceManagerNative.java:146)
06-24 16:19:39.449: E/System(62): at android.os.ServiceManager.addService(ServiceManager.java:72)
06-24 16:19:39.449: E/System(62): at com.android.server.ServerThread.run(SystemServer.java:206)
06-24 16:19:39.479: E/EventHub(62): could not get driver version for /dev/input/mouse0, Not a typewriter
06-24 16:19:39.479: E/EventHub(62): could not get driver version for /dev/input/mice, Not a typewriter
06-24 16:19:39.808: E/SoundPool(62): error loading /system/media/audio/ui/Effect_Tick.ogg
06-24 16:19:39.808: E/SoundPool(62): error loading /system/media/audio/ui/KeypressStandard.ogg
06-24 16:19:39.808: E/SoundPool(62): error loading /system/media/audio/ui/KeypressSpacebar.ogg
06-24 16:19:39.808: E/SoundPool(62): error loading /system/media/audio/ui/KeypressDelete.ogg
06-24 16:19:39.808: E/SoundPool(62): error loading /system/media/audio/ui/KeypressReturn.ogg
06-24 16:19:39.828: E/UsbObserver(62): java.lang.NullPointerException
06-24 16:19:39.828: E/UsbObserver(62): at com.android.server.UsbObserver.init(UsbObserver.java:131)
06-24 16:19:39.828: E/UsbObserver(62): at com.android.server.UsbObserver.<init>(UsbObserver.java:65)
06-24 16:19:39.828: E/UsbObserver(62): at com.android.server.ServerThread.run(SystemServer.java:402)
06-24 16:19:40.429: E/ThrottleService(62): Could not open GPS configuration file /etc/gps.conf
06-24 16:19:40.958: E/logwrapper(137): executing /system/bin/tc failed: No such file or directory
06-24 16:19:41.069: E/logwrapper(139): executing /system/bin/tc failed: No such file or directory
06-24 16:19:41.129: E/logwrapper(144): executing /system/bin/tc failed: No such file or directory
06-24 16:37:58.420: E/AndroidRuntime(345): FATAL EXCEPTION: main
06-24 16:37:58.420: E/AndroidRuntime(345): java.lang.IllegalStateException: Could not execute method of the activity
06-24 16:37:58.420: E/AndroidRuntime(345): at android.view.View$1.onClick(View.java:2144)
06-24 16:37:58.420: E/AndroidRuntime(345): at android.view.View.performClick(View.java:2485)
06-24 16:37:58.420: E/AndroidRuntime(345): at android.view.View$PerformClick.run(View.java:9080)
06-24 16:37:58.420: E/AndroidRuntime(345): at android.os.Handler.handleCallback(Handler.java:587)
06-24 16:37:58.420: E/AndroidRuntime(345): at android.os.Handler.dispatchMessage(Handler.java:92)
06-24 16:37:58.420: E/AndroidRuntime(345): at android.os.Looper.loop(Looper.java:123)
06-24 16:37:58.420: E/AndroidRuntime(345): at android.app.ActivityThread.main(ActivityThread.java:3683)
06-24 16:37:58.420: E/AndroidRuntime(345): at java.lang.reflect.Method.invokeNative(Native Method)
06-24 16:37:58.420: E/AndroidRuntime(345): at java.lang.reflect.Method.invoke(Method.java:507)
06-24 16:37:58.420: E/AndroidRuntime(345): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
06-24 16:37:58.420: E/AndroidRuntime(345): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
06-24 16:37:58.420: E/AndroidRuntime(345): at dalvik.system.NativeStart.main(Native Method)
06-24 16:37:58.420: E/AndroidRuntime(345): Caused by: java.lang.reflect.InvocationTargetException
06-24 16:37:58.420: E/AndroidRuntime(345): at java.lang.reflect.Method.invokeNative(Native Method)
06-24 16:37:58.420: E/AndroidRuntime(345): at java.lang.reflect.Method.invoke(Method.java:507)
06-24 16:37:58.420: E/AndroidRuntime(345): at android.view.View$1.onClick(View.java:2139)
06-24 16:37:58.420: E/AndroidRuntime(345): ... 11 more
06-24 16:37:58.420: E/AndroidRuntime(345): Caused by: android.content.ActivityNotFoundException: Unable to find explicit activity class {com.myfirstapp/DisplayMessageActivity.java.DisplayMessageActivity}; have you declared this activity in your AndroidManifest.xml?
06-24 16:37:58.420: E/AndroidRuntime(345): at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1405)
06-24 16:37:58.420: E/AndroidRuntime(345): at android.app.Instrumentation.execStartActivity(Instrumentation.java:1379)
06-24 16:37:58.420: E/AndroidRuntime(345): at android.app.Activity.startActivityForResult(Activity.java:2827)
06-24 16:37:58.420: E/AndroidRuntime(345): at android.app.Activity.startActivity(Activity.java:2933)
06-24 16:37:58.420: E/AndroidRuntime(345): at com.myfirstapp.MyFirstActivity.sendMessage(MyFirstActivity.java:26)
06-24 16:37:58.420: E/AndroidRuntime(345): ... 14 more
06-24 16:38:47.529: E/AndroidRuntime(357): FATAL EXCEPTION: main
06-24 16:38:47.529: E/AndroidRuntime(357): java.lang.IllegalStateException: Could not execute method of the activity
06-24 16:38:47.529: E/AndroidRuntime(357): at android.view.View$1.onClick(View.java:2144)
06-24 16:38:47.529: E/AndroidRuntime(357): at android.view.View.performClick(View.java:2485)
06-24 16:38:47.529: E/AndroidRuntime(357): at android.view.View$PerformClick.run(View.java:9080)
06-24 16:38:47.529: E/AndroidRuntime(357): at android.os.Handler.handleCallback(Handler.java:587)
06-24 16:38:47.529: E/AndroidRuntime(357): at android.os.Handler.dispatchMessage(Handler.java:92)
06-24 16:38:47.529: E/AndroidRuntime(357): at android.os.Looper.loop(Looper.java:123)
06-24 16:38:47.529: E/AndroidRuntime(357): at android.app.ActivityThread.main(ActivityThread.java:3683)
06-24 16:38:47.529: E/AndroidRuntime(357): at java.lang.reflect.Method.invokeNative(Native Method)
06-24 16:38:47.529: E/AndroidRuntime(357): at java.lang.reflect.Method.invoke(Method.java:507)
06-24 16:38:47.529: E/AndroidRuntime(357): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
06-24 16:38:47.529: E/AndroidRuntime(357): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
06-24 16:38:47.529: E/AndroidRuntime(357): at dalvik.system.NativeStart.main(Native Method)
06-24 16:38:47.529: E/AndroidRuntime(357): Caused by: java.lang.reflect.InvocationTargetException
06-24 16:38:47.529: E/AndroidRuntime(357): at java.lang.reflect.Method.invokeNative(Native Method)
06-24 16:38:47.529: E/AndroidRuntime(357): at java.lang.reflect.Method.invoke(Method.java:507)
06-24 16:38:47.529: E/AndroidRuntime(357): at android.view.View$1.onClick(View.java:2139)
06-24 16:38:47.529: E/AndroidRuntime(357): ... 11 more
06-24 16:38:47.529: E/AndroidRuntime(357): Caused by: android.content.ActivityNotFoundException: Unable to find explicit activity class {com.myfirstapp/DisplayMessageActivity.java.DisplayMessageActivity}; have you declared this activity in your AndroidManifest.xml?
06-24 16:38:47.529: E/AndroidRuntime(357): at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1405)
06-24 16:38:47.529: E/AndroidRuntime(357): at android.app.Instrumentation.execStartActivity(Instrumentation.java:1379)
06-24 16:38:47.529: E/AndroidRuntime(357): at android.app.Activity.startActivityForResult(Activity.java:2827)
06-24 16:38:47.529: E/AndroidRuntime(357): at android.app.Activity.startActivity(Activity.java:2933)
06-24 16:38:47.529: E/AndroidRuntime(357): at com.myfirstapp.MyFirstActivity.sendMessage(MyFirstActivity.java:26)
06-24 16:38:47.529: E/AndroidRuntime(357): ... 14 more
06-24 16:43:20.070: E/AndroidRuntime(385): FATAL EXCEPTION: main
06-24 16:43:20.070: E/AndroidRuntime(385): java.lang.IllegalStateException: Could not execute method of the activity
06-24 16:43:20.070: E/AndroidRuntime(385): at android.view.View$1.onClick(View.java:2144)
06-24 16:43:20.070: E/AndroidRuntime(385): at android.view.View.performClick(View.java:2485)
06-24 16:43:20.070: E/AndroidRuntime(385): at android.view.View$PerformClick.run(View.java:9080)
06-24 16:43:20.070: E/AndroidRuntime(385): at android.os.Handler.handleCallback(Handler.java:587)
06-24 16:43:20.070: E/AndroidRuntime(385): at android.os.Handler.dispatchMessage(Handler.java:92)
06-24 16:43:20.070: E/AndroidRuntime(385): at android.os.Looper.loop(Looper.java:123)
06-24 16:43:20.070: E/AndroidRuntime(385): at android.app.ActivityThread.main(ActivityThread.java:3683)
06-24 16:43:20.070: E/AndroidRuntime(385): at java.lang.reflect.Method.invokeNative(Native Method)
06-24 16:43:20.070: E/AndroidRuntime(385): at java.lang.reflect.Method.invoke(Method.java:507)
06-24 16:43:20.070: E/AndroidRuntime(385): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
06-24 16:43:20.070: E/AndroidRuntime(385): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
06-24 16:43:20.070: E/AndroidRuntime(385): at dalvik.system.NativeStart.main(Native Method)
06-24 16:43:20.070: E/AndroidRuntime(385): Caused by: java.lang.reflect.InvocationTargetException
06-24 16:43:20.070: E/AndroidRuntime(385): at java.lang.reflect.Method.invokeNative(Native Method)
06-24 16:43:20.070: E/AndroidRuntime(385): at java.lang.reflect.Method.invoke(Method.java:507)
06-24 16:43:20.070: E/AndroidRuntime(385): at android.view.View$1.onClick(View.java:2139)
06-24 16:43:20.070: E/AndroidRuntime(385): ... 11 more
06-24 16:43:20.070: E/AndroidRuntime(385): Caused by: android.content.ActivityNotFoundException: Unable to find explicit activity class {com.myfirstapp/DisplayMessageActivity.java.DisplayMessageActivity}; have you declared this activity in your AndroidManifest.xml?
06-24 16:43:20.070: E/AndroidRuntime(385): at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1405)
06-24 16:43:20.070: E/AndroidRuntime(385): at android.app.Instrumentation.execStartActivity(Instrumentation.java:1379)
06-24 16:43:20.070: E/AndroidRuntime(385): at android.app.Activity.startActivityForResult(Activity.java:2827)
06-24 16:43:20.070: E/AndroidRuntime(385): at android.app.Activity.startActivity(Activity.java:2933)
06-24 16:43:20.070: E/AndroidRuntime(385): at com.myfirstapp.MyFirstActivity.sendMessage(MyFirstActivity.java:26)
06-24 16:43:20.070: E/AndroidRuntime(385): ... 14 more
06-24 16:45:09.099: E/AndroidRuntime(425): FATAL EXCEPTION: main
06-24 16:45:09.099: E/AndroidRuntime(425): java.lang.IllegalStateException: Could not execute method of the activity
06-24 16:45:09.099: E/AndroidRuntime(425): at android.view.View$1.onClick(View.java:2144)
06-24 16:45:09.099: E/AndroidRuntime(425): at android.view.View.performClick(View.java:2485)
06-24 16:45:09.099: E/AndroidRuntime(425): at android.view.View$PerformClick.run(View.java:9080)
06-24 16:45:09.099: E/AndroidRuntime(425): at android.os.Handler.handleCallback(Handler.java:587)
06-24 16:45:09.099: E/AndroidRuntime(425): at android.os.Handler.dispatchMessage(Handler.java:92)
06-24 16:45:09.099: E/AndroidRuntime(425): at android.os.Looper.loop(Looper.java:123)
06-24 16:45:09.099: E/AndroidRuntime(425): at android.app.ActivityThread.main(ActivityThread.java:3683)
06-24 16:45:09.099: E/AndroidRuntime(425): at java.lang.reflect.Method.invokeNative(Native Method)
06-24 16:45:09.099: E/AndroidRuntime(425): at java.lang.reflect.Method.invoke(Method.java:507)
06-24 16:45:09.099: E/AndroidRuntime(425): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
06-24 16:45:09.099: E/AndroidRuntime(425): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
06-24 16:45:09.099: E/AndroidRuntime(425): at dalvik.system.NativeStart.main(Native Method)
06-24 16:45:09.099: E/AndroidRuntime(425): Caused by: java.lang.reflect.InvocationTargetException
06-24 16:45:09.099: E/AndroidRuntime(425): at java.lang.reflect.Method.invokeNative(Native Method)
06-24 16:45:09.099: E/AndroidRuntime(425): at java.lang.reflect.Method.invoke(Method.java:507)
06-24 16:45:09.099: E/AndroidRuntime(425): at android.view.View$1.onClick(View.java:2139)
06-24 16:45:09.099: E/AndroidRuntime(425): ... 11 more
06-24 16:45:09.099: E/AndroidRuntime(425): Caused by: android.content.ActivityNotFoundException: Unable to find explicit activity class {com.myfirstapp/DisplayMessageActivity.java.DisplayMessageActivity}; have you declared this activity in your AndroidManifest.xml?
06-24 16:45:09.099: E/AndroidRuntime(425): at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1405)
06-24 16:45:09.099: E/AndroidRuntime(425): at android.app.Instrumentation.execStartActivity(Instrumentation.java:1379)
06-24 16:45:09.099: E/AndroidRuntime(425): at android.app.Activity.startActivityForResult(Activity.java:2827)
06-24 16:45:09.099: E/AndroidRuntime(425): at android.app.Activity.startActivity(Activity.java:2933)
06-24 16:45:09.099: E/AndroidRuntime(425): at com.myfirstapp.MyFirstActivity.sendMessage(MyFirstActivity.java:26)
06-24 16:45:09.099: E/AndroidRuntime(425): ... 14 more
06-24 18:20:31.070: E/AndroidRuntime(464): FATAL EXCEPTION: main
06-24 18:20:31.070: E/AndroidRuntime(464): java.lang.IllegalStateException: Could not execute method of the activity
06-24 18:20:31.070: E/AndroidRuntime(464): at android.view.View$1.onClick(View.java:2144)
06-24 18:20:31.070: E/AndroidRuntime(464): at android.view.View.performClick(View.java:2485)
06-24 18:20:31.070: E/AndroidRuntime(464): at android.view.View$PerformClick.run(View.java:9080)
06-24 18:20:31.070: E/AndroidRuntime(464): at android.os.Handler.handleCallback(Handler.java:587)
06-24 18:20:31.070: E/AndroidRuntime(464): at android.os.Handler.dispatchMessage(Handler.java:92)
06-24 18:20:31.070: E/AndroidRuntime(464): at android.os.Looper.loop(Looper.java:123)
06-24 18:20:31.070: E/AndroidRuntime(464): at android.app.ActivityThread.main(ActivityThread.java:3683)
06-24 18:20:31.070: E/AndroidRuntime(464): at java.lang.reflect.Method.invokeNative(Native Method)
06-24 18:20:31.070: E/AndroidRuntime(464): at java.lang.reflect.Method.invoke(Method.java:507)
06-24 18:20:31.070: E/AndroidRuntime(464): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
06-24 18:20:31.070: E/AndroidRuntime(464): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
06-24 18:20:31.070: E/AndroidRuntime(464): at dalvik.system.NativeStart.main(Native Method)
06-24 18:20:31.070: E/AndroidRuntime(464): Caused by: java.lang.reflect.InvocationTargetException
06-24 18:20:31.070: E/AndroidRuntime(464): at java.lang.reflect.Method.invokeNative(Native Method)
06-24 18:20:31.070: E/AndroidRuntime(464): at java.lang.reflect.Method.invoke(Method.java:507)
06-24 18:20:31.070: E/AndroidRuntime(464): at android.view.View$1.onClick(View.java:2139)
06-24 18:20:31.070: E/AndroidRuntime(464): ... 11 more
06-24 18:20:31.070: E/AndroidRuntime(464): Caused by: android.content.ActivityNotFoundException: Unable to find explicit activity class {com.myfirstapp/DisplayMessageActivity.java.DisplayMessageActivity}; have you declared this activity in your AndroidManifest.xml?
06-24 18:20:31.070: E/AndroidRuntime(464): at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1405)
06-24 18:20:31.070: E/AndroidRuntime(464): at android.app.Instrumentation.execStartActivity(Instrumentation.java:1379)
06-24 18:20:31.070: E/AndroidRuntime(464): at android.app.Activity.startActivityForResult(Activity.java:2827)
06-24 18:20:31.070: E/AndroidRuntime(464): at android.app.Activity.startActivity(Activity.java:2933)
06-24 18:20:31.070: E/AndroidRuntime(464): at com.myfirstapp.MyFirstActivity.sendMessage(MyFirstActivity.java:26)
06-24 18:20:31.070: E/AndroidRuntime(464): ... 14 more
06-24 18:25:12.590: E/AndroidRuntime(477): FATAL EXCEPTION: main
06-24 18:25:12.590: E/AndroidRuntime(477): java.lang.IllegalStateException: Could not execute method of the activity
06-24 18:25:12.590: E/AndroidRuntime(477): at android.view.View$1.onClick(View.java:2144)
06-24 18:25:12.590: E/AndroidRuntime(477): at android.view.View.performClick(View.java:2485)
06-24 18:25:12.590: E/AndroidRuntime(477): at android.view.View$PerformClick.run(View.java:9080)
06-24 18:25:12.590: E/AndroidRuntime(477): at android.os.Handler.handleCallback(Handler.java:587)
06-24 18:25:12.590: E/AndroidRuntime(477): at android.os.Handler.dispatchMessage(Handler.java:92)
06-24 18:25:12.590: E/AndroidRuntime(477): at android.os.Looper.loop(Looper.java:123)
06-24 18:25:12.590: E/AndroidRuntime(477): at android.app.ActivityThread.main(ActivityThread.java:3683)
06-24 18:25:12.590: E/AndroidRuntime(477): at java.lang.reflect.Method.invokeNative(Native Method)
06-24 18:25:12.590: E/AndroidRuntime(477): at java.lang.reflect.Method.invoke(Method.java:507)
06-24 18:25:12.590: E/AndroidRuntime(477): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
06-24 18:25:12.590: E/AndroidRuntime(477): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
06-24 18:25:12.590: E/AndroidRuntime(477): at dalvik.system.NativeStart.main(Native Method)
06-24 18:25:12.590: E/AndroidRuntime(477): Caused by: java.lang.reflect.InvocationTargetException
06-24 18:25:12.590: E/AndroidRuntime(477): at java.lang.reflect.Method.invokeNative(Native Method)
06-24 18:25:12.590: E/AndroidRuntime(477): at java.lang.reflect.Method.invoke(Method.java:507)
06-24 18:25:12.590: E/AndroidRuntime(477): at android.view.View$1.onClick(View.java:2139)
06-24 18:25:12.590: E/AndroidRuntime(477): ... 11 more
06-24 18:25:12.590: E/AndroidRuntime(477): Caused by: android.content.ActivityNotFoundException: Unable to find explicit activity class {com.myfirstapp/DisplayMessageActivity.java.DisplayMessageActivity}; have you declared this activity in your AndroidManifest.xml?
06-24 18:25:12.590: E/AndroidRuntime(477): at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1405)
06-24 18:25:12.590: E/AndroidRuntime(477): at android.app.Instrumentation.execStartActivity(Instrumentation.java:1379)
06-24 18:25:12.590: E/AndroidRuntime(477): at android.app.Activity.startActivityForResult(Activity.java:2827)
06-24 18:25:12.590: E/AndroidRuntime(477): at android.app.Activity.startActivity(Activity.java:2933)
06-24 18:25:12.590: E/AndroidRuntime(477): at com.myfirstapp.MyFirstActivity.sendMessage(MyFirstActivity.java:26)
06-24 18:25:12.590: E/AndroidRuntime(477): ... 14 more
<code>
not sure as how to debug this app.
Please advice
Thanks
SSAMEERR
Unable to find explicit activity class
{com.myfirstapp/DisplayMessageActivity.java.DisplayMessageActivity};
have you declared this activity in your AndroidManifest.xml?
put the entry of the DisplayMessageActivity in manifest.......
it DisplayMessageActivity is first Activity use intent-filter other remove that.
<activity android:name=".DisplayMessageActivity" android:label="Demo App">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
Add it to the DisplayMessageActivity manifest as
<application ... >
<activity android:name=".DisplayMessageActivity" />
...
</application>
The answer is in the logcat:
Caused by: android.content.ActivityNotFoundException: Unable to find explicit activity class {com.myfirstapp/DisplayMessageActivity.java.DisplayMessageActivity}; have you declared this activity in your AndroidManifest.xml?
Declare the activity in your manifest like so (i.e. insert it somewhere between the <application> and </application> tags):
<activity android:name=".DisplayMessageActivity" />
This is a common beginners mistake... expect this error at least a couple more times before you get used to it. :)
Make sure your other activities in the project are added to the AndroidManifest.xml
You have to include your activity in Manifest like:
<activity android:name=".MyFirstActivity"
android:theme="#android:style/Theme.NoTitleBar">
</activity>

location-based application development testing on actual device

I am trying an example given in o reilys book and testing it on LG P500 but all I get is force close with the following errors:
WARNING: Application does not specify an API level requirement!
[2011-11-09 15:43:38 - dloc] Device API version is 8 (Android 2.2.2)
**p.s i have mentioned api level**
**logcat:**
11-09 16:00:44.738: W/dalvikvm(8002): threadid=1: thread exiting with uncaught exception (group=0x40020ac0)
11-09 16:00:44.738: E/AndroidRuntime(8002): FATAL EXCEPTION: main
11-09 16:00:44.738: E/AndroidRuntime(8002): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.microjobsinc.dloc/com.microjobsinc.dloc.Main}: java.lang.ClassNotFoundException: com.microjobsinc.dloc.Main in loader dalvik.system.PathClassLoader[/data/app/com.microjobsinc.dloc-2.apk]
11-09 16:00:44.738: E/AndroidRuntime(8002): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2585)
11-09 16:00:44.738: E/AndroidRuntime(8002): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
11-09 16:00:44.738: E/AndroidRuntime(8002): at android.app.ActivityThread.access$2300(ActivityThread.java:125)
11-09 16:00:44.738: E/AndroidRuntime(8002): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
11-09 16:00:44.738: E/AndroidRuntime(8002): at android.os.Handler.dispatchMessage(Handler.java:99)
11-09 16:00:44.738: E/AndroidRuntime(8002): at android.os.Looper.loop(Looper.java:123)
11-09 16:00:44.738: E/AndroidRuntime(8002): at android.app.ActivityThread.main(ActivityThread.java:4627)
11-09 16:00:44.738: E/AndroidRuntime(8002): at java.lang.reflect.Method.invokeNative(Native Method)
11-09 16:00:44.738: E/AndroidRuntime(8002): at java.lang.reflect.Method.invoke(Method.java:521)
11-09 16:00:44.738: E/AndroidRuntime(8002): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
11-09 16:00:44.738: E/AndroidRuntime(8002): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
11-09 16:00:44.738: E/AndroidRuntime(8002): at dalvik.system.NativeStart.main(Native Method)
11-09 16:00:44.738: E/AndroidRuntime(8002): Caused by: java.lang.ClassNotFoundException: com.microjobsinc.dloc.Main in loader dalvik.system.PathClassLoader[/data/app/com.microjobsinc.dloc-2.apk]
11-09 16:00:44.738: E/AndroidRuntime(8002): at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:243)
11-09 16:00:44.738: E/AndroidRuntime(8002): at java.lang.ClassLoader.loadClass(ClassLoader.java:573)
11-09 16:00:44.738: E/AndroidRuntime(8002): at java.lang.ClassLoader.loadClass(ClassLoader.java:532)
11-09 16:00:44.738: E/AndroidRuntime(8002): at android.app.Instrumentation.newActivity(Instrumentation.java:1021)
11-09 16:00:44.738: E/AndroidRuntime(8002): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2577)
11-09 16:00:44.738: E/AndroidRuntime(8002): ... 11 more
11-09 16:00:49.848: W/dalvikvm(8013): threadid=1: thread exiting with uncaught exception (group=0x40020ac0)
11-09 16:00:49.858: E/AndroidRuntime(8013): FATAL EXCEPTION: main
Code is written below
public class main extends Activity {
/** Called when the activity is first created. */
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
// find the TextViews
TextView tvLatitude = (TextView)findViewById(R.id.tvLatitude);
TextView tvLongitude = (TextView)findViewById(R.id.tvLongitude);
// get handle for LocationManager
LocationManager lm = (LocationManager)getSystemService(Context.LOCATION_SERVICE);
// connect to the GPS location service
String providerName = LocationManager.GPS_PROVIDER;
Location loc = lm.getLastKnownLocation( providerName);
// fill in the TextViews
tvLatitude.setText(Double.toString(loc.getLatitude()));
tvLongitude.setText(Double.toString(loc.getLongitude()));
}
}
What is the cause of this problem and how can I fix it?
You need to change the android project properties to use Google Apis with the platform version that you desire.

Categories

Resources