drmrbrewer
drmrbrewer

Reputation: 13019

How to read crash reports from Developer Console

I'm trying to track down the source of a bug, based on a crash report submitted by a user, and have come to the conclusion that I need some basic training on how to interpret a crash report.

As an example, the crash report is as follows:

java.lang.NumberFormatException: Invalid int: ""
    at java.lang.Integer.invalidInt(Integer.java:138)
    at java.lang.Integer.parseInt(Integer.java:358)
    at java.lang.Integer.parseInt(Integer.java:334)
    at java.lang.Integer.valueOf(Integer.java:525)
    at com.cloud3squared.meteogram.MeteogramService.cacheFileName(MeteogramService.java)
                                                    cacheBaseName(MeteogramService.java)
                                                    getAppWidgetId(MeteogramService.java)
                                                    createAdhocWidgetUpdateIntent(MeteogramService.java)
                                                    setupBasicClickStuff(MeteogramService.java)
                                                    setAdhocAppWidgetAlarm(MeteogramService.java)
                                                    setNextClockWidgetUpdateAlarm(MeteogramService.java)
                                                    cancelAppWidgetAlarm(MeteogramService.java)
                                                    cancelAppWidgetAlarms(MeteogramService.java)
                                                    logAction$3aaf2084(MeteogramService.java)
                                                    logActionAgainstAllWidgets$62dc3a79(MeteogramService.java)
                                                    updateAppWidget(MeteogramService.java)
                                                    showButtons(MeteogramService.java)
                                                    hideButtons(MeteogramService.java)
                                                    fetchOk(MeteogramService.java)
                                                    getViewId(MeteogramService.java)
                                                    putBitmapIntoWidget(MeteogramService.java)
                                                    lngNow(MeteogramService.java)
                                                    showNotification(MeteogramService.java)
                                                    showMessageInWidget(MeteogramService.java)
                                                    sharpen(MeteogramService.java)
                                                    removeFromRequestsList(MeteogramService.java)
                                                    removeFromRequestsList$204347ff(MeteogramService.java)
                                                                           MeteogramService.java)
                                                    displayStuffInWidget(MeteogramService.java)
                                                    access$000(MeteogramService.java)
                                                    access$100(MeteogramService.java)
                                                    access$300(MeteogramService.java)
    at com.cloud3squared.meteogram.MeteogramService$GetServerWidgetAsyncTask.onPostExecute(MeteogramService.java)
    at android.os.AsyncTask.finish(AsyncTask.java:651)
    at android.os.AsyncTask.access$500(AsyncTask.java:180)
    at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:668)
    at android.os.Handler.dispatchMessage(Handler.java:102)
    at android.os.Looper.loop(Looper.java:224)
    at android.app.ActivityThread.main(ActivityThread.java:5526)
    at java.lang.reflect.Method.invoke(Method.java)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)

Is this showing the order of calls leading up to the NumberFormatException, and if so, in what order? Do I read the at lines from bottom to top? What is access nested inside MeteogramService?... there is no access method in that class. How do I determine inside which function the NumberFormatException actually occurs? Logically I would say inside cacheFileName but there is nothing in there that might lead to such an exception... the parsing of a String to an int happens before that... the parsed int is simply passed into cacheFileName.

Any help gratefully received.

EDIT

Further code snippets to refer to in comments below:

static String cacheFileName(Context context, int appWidgetId, int pxWidth, int pxHeight) {
    String fileName = cacheBaseName(appWidgetId) + "_" + pxWidth + "x" + pxHeight + ".png";
    logAction(context, appWidgetId, "cacheFileName " + fileName, TAG);
    return fileName;
}

static String cacheBaseName(int appWidgetId) {
    return (appWidgetId == AppWidgetManager.INVALID_APPWIDGET_ID) ? "widget_" : "widget_" + appWidgetId;
}

Upvotes: 10

Views: 609

Answers (4)

Nagaraju Gajula
Nagaraju Gajula

Reputation: 560

The error is in MeteogramService.java file.

The error NumberFormatException is due to an invalid int value, which is possibly because of passing a string or invalid variable into an int.

The list of class names or method names is the order from top to bottom in which the variable has been accessed. Verify if you are passing an int, and in case if it is user defined value, then use a try/catch block and show toast whenever they enter a non-int value.

Upvotes: 3

TechGamer27
TechGamer27

Reputation: 68

I agree with the others,

Typically with crash reports, you want to look for the exception, in this case a NumberFormatException, and then for your class package name.

Assuming your package is com.cloud3squared.meteogram., the problem is from your Meteogram Service and you are using Integer.parseInt() wrong.

Note that for Integer.parseInt(), you need a string that has a number in it like "3" or "5". If it doesn't have this, the method will crash with a NumberFormatException. I don't see that method call in your cacheFileName() class so I recommend you search through getAppWidgetID() and other method calls through the stack trace.

Upvotes: 0

TWL
TWL

Reputation: 6646

You have to read it BOTH from top to bottom and bottom to top.

It's typically more specific from the top to broader at the bottom.

From the TOP: you will find the precise cause of exception

Which in this case is java.lang.NumberFormatException which blows up at cacheFileName's cacheBaseName

From the BOTTOM: you will find the general area of the problem

GetServerWidgetAsyncTask.onPostExecute

What this looks like to me is that it could be some value finished in the background work in the AsyncTask is improperly formatted and used as an int in onPostExecute.

Where I would start off is to debug the values of: pxWidth, pxHeight, and appWidgetId in String fileName = cacheBaseName(appWidgetId) + "_" + pxWidth + "x" + pxHeight + ".png";

Integer.valueOf means it was probably trying to parse a string into an int, example: String "13" into int 13.

Out of those 3 variables, the most probable relation is the appWidgetId since there is another tip about getAppWidgetId. But to be sure, log all 3! =)

Upvotes: 3

Ankit Aggarwal
Ankit Aggarwal

Reputation: 5375

Is this showing the order of calls leading up to the NumberFormatException

Yes this stack trace is definitely showing you the order of calls leading upto the exception. Read your stack trace from bottom to top to know the order of method calls -

What is access nested inside MeteogramService?... there is no access method in that class

these access methods are automatically generated methods to access members of a outer class from inner class. For more details check this video by Jake Wharton.

How do I determine inside which function the NumberFormatException actually occurs

Check all the method calls in the stack trace. The top ones will tell you from which method the exception is thrown first. So if you check the stack trace, method calls in lines 2 to 4 are from Integer.java class which is a class not defined by you but the exception is initiated from this class. Now if you come to line 5, it clearly tells you that the next method call is MeteogramService.cacheFileName(). So the exception has arised when you try to do something from this method.

there is nothing in there that might lead to such an exception

Read your stack trace carefully. In the very first line it says java.lang.NumberFormatException: Invalid int: "". It means you are passing empty string or "" to the integer class. Now if you check the line before MeteogramService.cacheFileName() it says java.lang.Integer.valueOf() method has been called by you.

Hence the conclusion is you are calling valueOf() method on and empty String which is not a valid Integer and hence the NumberFormatException

Upvotes: 2

Related Questions