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;
}
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! =)
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With