Android API –

We all know there are some methods and/or values in the Android API that sound funny and seem to have no purpose. Lets deep dive into a single method and find out its history.

For this blog we will have a look at the method:

This method is available in the Log class from Android. It is introduced in API 8 (Android 2.2) and it returns a int value.

The description says:

What a Terrible Failure: Report a condition that should never happen.


The error will always be logged at level ASSERT with the call stack.

Now this bit is interesting, it seems that only uses the ASSERT priority constant! Lets investigate further.

Depending on system configuration, a report may be added to the DropBoxManager and/or the process may be terminated immediately with an error dialog.

Now we know as much as any developer at this point. But what was the reason behind this? It doesn’t seem to be an easteregg! The first step was to look into the source code of this method.

Source code here.

Basicly what i’m reading here is that Android is lying to us. The methods doesn’t use the ASSERT constant after all. It is hardcoded to be ERROR. So, and Log.e() both have the same priority, ERROR. The difference is that calls for onTerribleFailure() call back.

It seems the RuntimeInit class calls the wtf() method when this happens. So I continued the search.

When checking the wtf() method on the RuntimeInit class it seems its the task of the ActivityManager to check if we need to abort the system or not. The description of this method also makes this clear.

“Report a serious error in the current process. May or may not cause the process to terminate (depends on system settings)”

I wanted to go deeper but the code became to complicated to really understand this. Post in the comments if you know when precisely the system will abort!

Bottom line: Do not use as replacement of Log.e() because it sounds funny! could crash your app.


Add a Comment

Your email address will not be published. Required fields are marked *