Thread.setDefaultUncaughtExceptionHandler for Errors - java

I am working on an Android app where for uncaught exceptions I do this
Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler()...);
This way when an uncaught exception is thrown I log it and send a request to my issue tracker to create a new issue. I would like to do the same for errors. Is there a way to intercept uncaught errors in Java or Android? I have combed through stackoverflow and Google and have not found anything.

After comments on the functionality of this and the fact that I was not able to find any info regarding this, and not being able to find and info related to this, I did some testing and it does in fact get called when an error is thrown as well. The name is misleading but it does in fact work with errors as well. Thanks to the comments for the guidance.

Related

How to detect cause of this crash from Crashlytics?

Suddenly my app started to crash enormously. I checked Crashlytics report but it doesn't tell me much. This is what it says, hopefully someone could give me a hint if had same/similar problem..
This seems to be related to a known jmDNS bug that was supposedly fixed a long time ago1:
https://sourceforge.net/p/jmdns/bugs/101/
https://sourceforge.net/p/jmdns/mailman/jmdns-discuss/thread/4EA5B242.4070003#gmail.com/
Apparently, the problem is triggered by lookup of malformed DNS names: see last email in discussion thread.
I suggest that you add some diagnostics to your app to find out what name your code is attempting to lookup.
1 - I have my doubts that it was actually fixed ... based on the discussion thread.

Android system throwing ErrnoException (2) before my launcher activity runs

I've started having this weird issue where the code would run normally in 'Run', but any sort of debugging would cause the device to throw an ErrnoException with errno = 2. I haven't been able to find what errno 2 means. My code here is irrelevant, since even the first line of code isn't reached. Attached is a picture of my stack trace. Notice how "Variable debug info [is] not available", and "this" is not shown in the var list.
If this actually helps anyone:
Let me know what you need, I'll get back to you quickly, and thanks in advance!
EDIT 1: Logcat verbose during exception
NOTE: package name is blurred
I imagine that you figured this out a while ago, but let's get the answer in here for others reading this...
You are probably set up to break on all exceptions. This is a normal exception thrown by some part of the Android launching system. If you continue past it, the Exception will be caught by Android and your app will launch as usual.

null pointer exception when programming for android phone from processing IDE

i am relatively new to java programming and programming for android and have been experimenting with android bluetooth comms using the Ketai library for the processing IDE specifically for use with android and tried to run the example program bluetoothcursors.pde that comes with the library but i keep getting the "application has stopped unexpectedly" error and the console indicates a null pointer exception error. The actual output is below:
FATAL EXCEPTION: Animation Thread
java.lang.NullPointerException
at ketai.net.bluetooth.KBluetoothListener.<init>(KBluetoothListener.java:56)
at ketai.net.bluetooth.KetaiBluetooth.start(KetaiBluetooth.java:207)
at processing.test.bluetoothcursors.BluetoothCursors.setup(BluetoothCursors.java:80)
at processing.core.PApplet.handleDraw(Unknown Source)
at processing.core.PGraphicsAndroid2D.requestDraw(Unknown Source)
at processing.core.PApplet.run(Unknown Source)
at java.lang.Thread.run(Thread.java:1019)
However i cant seem to see where the null pointer exception is coming from. I assume the null pointer exception relates to a variable that has not been instantiated properly. I have tried a process of elimination to try and isolate the cause but i get the same error but with slightly different source. I have also posted this question on the processing forum but have not received a reply. I just assumed that since it was part of the examples for the library it would work so maybe the error is being created somewhere else. I have tried other library examples and theses all work fine so i dont think its my setup. I also have other bluetooth programs working on android from processing but these use pure java code and are harder to follow.
I have had a look at some of the similar questions which have been sort-of helpful but i am still stuck.
I have set the correct bluetooth etc permissions and am using android version 2.3.3 and processing version 2.0.
Any help with this is much appreciated.
Cheers.

Java/SWT: an error has occurred see log for more

We are seeing this very generic error pop up in some circumstances, but we can't seem to track down what is generating it and I'm hoping someone has some insight into where to begin. We have multiple client machines all running the same version of our software, build with SWT, and all hitting the same server, but not everyone gets this error. Nothing is showing up in our client or server logs and I have no idea what log file this error may be referring to, so it's not an error that we are catching anywhere and we have no details about this. Since it's a pop-up message that leads me to think it may be an SWT error. I've seen people mention this error when using Eclipse, but I haven't found where anyone mentioned it in an application they built.
I know this is vague, but I don't have much more to go on. Does anyone have an idea where to start looking for culprits?
Thanks
You're building an RCP application? In that case, this error is talking about the Eclipse platform log.
There should be a .metadata\.log file in your program's instance location. If you do not know your instance location, you can query it by calling:
Platform.getInstanceLocation();

NullPointerException in handleStopActivity -- No reference to my code in stack trace

I'm a bit at a loss, here. I've been seeing a steadily increasing number of these NullPointerExceptions in handleStopActivity. I suspect that the increase coinicides with the increase in 2.2 upgrades to Droid owners, though that's just a guess. I've never seen the crash myself, and the stack trace provided by the market does not mention any of the classes I've written. As such, I have no idea where to start in fixing the problem.
java.lang.NullPointerException
at android.app.ActivityThread.handleStopActivity(ActivityThread.java:3674)
at android.app.ActivityThread.access$2600(ActivityThread.java:135)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2153)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:144)
at android.app.ActivityThread.main(ActivityThread.java:4937)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:521)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
at dalvik.system.NativeStart.main(Native Method)
Since I don't know the cause, I also don't know what information to provide to aid in diagnosis, so I'll give an overiew:
My app is WootWatcher. It tracks Woot.com and notifies users of new items for sale. It does this by means of a service that runs in a separate process. The service and the main activity communicate with each other via aidl interface and callback. I also make use of message handlers in both the service and activity, and frequently spawn threads for expensive tasks.
Looking back at this 4-year old question, I realize I should be able to diagnose it, but unfortunately I can't find any version of AOSP for which these lines match up. The Droid must have used some altered version of the source that wasn't made available.
That said, Froyo's handleStopActivity() doesn't have many opportunities for a null pointer exception. The most likely one would point to Activity.finish() when the Activity has already been stopped, or is in the process of being stopped.
This usually happens when you register listeners that eventually call finish() and you don't unregister those listeners in onPause().
How about reporting a bug to Android Project (would mandate checking if anyone else reported it) ? If no code from You is in the stack trace, that would signal a bug in the framework. Although maybe in your other code You break e.g. an unspoken contract/assumption.
Refer the answer in this question. Looks like a known problem and has a solution too.
Hope it helps...
NullPointerException on onSaveInstanceState with AndroidFragments
I don't know, if you're still looking for a solution, but here's what I found out. If you have found a real solution, please let me know.
I just had the same issue.. I never had that problem and without changing code, it appeared for some reason. By using google, I found the question that Joseph posted, but that doesn't seem to be exactly the same. I also found this and this. These two seem to have the same issue, but no solution.. Then I found this blog.
The author tells something about what it's from - a bug in Android. Further, it has to do with a Cursor. That didn't fix my issue, but I noticed, that I used a Cursor, a few lines before calling startActivity(someIntent); (I also called finish(), but removing that line didn't make a difference).
I tried to remove the lines that include the Cursor and suddenly it works again..
I have no idea, why it works, but it does. I just moved the code with the Cursor to my other Activity.
It's definitly not a good solution, but it works for me.
There's just one more question: Do you even use a Cursor and call startActivity(..) or something similar?
Edit:
I just found out, that I didn't fix the problem, I just didn't test enough. The Activity I started was running fine until I wanted to create the next Activity out of that Activity I started before. On starting the next Activity, my App crashes again.
Maybe try wrapping the method handleStopActivity in try-catch block and handle the error yourself, giving yourself more details and preventing "force-close" ?

Categories