Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Debugging Android RuntimeException - Before my code even executes

Tags:

android

I'm not new to Java but new to the Android platform. I'm finding one of the platforms shortcomings to be meaningful feedback on runtime crashes. Fine in user code where breakpoints apply, but I have a crash on first run that is preventing my project from starting, and I can't see a way to track it down. Can anyone shed any light?

DalvikVM[localhost:8626]    
    Thread [<1> main] (Suspended (exception RuntimeException))  
        ActivityThread.performLaunchActivity(ActivityThread$ActivityRecord, Intent) line: 2585  
        ActivityThread.handleLaunchActivity(ActivityThread$ActivityRecord, Intent) line: 2679   
        ActivityThread.access$2300(ActivityThread, ActivityThread$ActivityRecord, Intent) line: 125 
        ActivityThread$H.handleMessage(Message) line: 2033  
        ActivityThread$H(Handler).dispatchMessage(Message) line: 99 
        Looper.loop() line: 123 
        ActivityThread.main(String[]) line: 4627    
        Method.invokeNative(Object, Object[], Class, Class[], Class, int, boolean) line: not available [native method]  
        Method.invoke(Object, Object...) line: 521  
        ZygoteInit$MethodAndArgsCaller.run() line: 868  
        ZygoteInit.main(String[]) line: 626 
        NativeStart.main(String[]) line: not available [native method]  
    Thread [<6> Binder Thread #2] (Running) 
    Thread [<5> Binder Thread #1] (Running) 

Same on emulator and device.

I've seen reports of crashes like these being caused by inflation of invalid XML so I have removed all XML's and resources from my project, almost one by one, and the same error remains! Are there any tricks or instrumentation I can apply to try and get a more meaningful error message? Thanks.

like image 578
Chris Hatton Avatar asked Dec 04 '22 10:12

Chris Hatton


1 Answers

I found the answer to gleaning more information in these situations. This page has some very useful information: http://www.mail-archive.com/[email protected]/msg79386.html

By opening the 'Variables' tab in the Debug section of Eclipse's views I could see there was a value named 'e' presumably for 'exception' with the value 'ClassNotFoundException'. By clicking on it I saw a fuller description saying the class that couldn't be found. It was my main Activity, which I'd renamed on a late night before, and forgotten about. Facepalm Hope this info helps someone!

like image 110
Chris Hatton Avatar answered May 23 '23 21:05

Chris Hatton