I’m trying to develop an application for Android, but I’m having difficulties tracing the source and cause of each exception I get in the process.
My code runs in an Activity, and if a line of mine causes an exception, then rather than stopping on that line and highlighting it, it throws me into the ActivityThread class’s code, which apparently I don’t have, so I just get a “Source not found” screen.
Trying to find the troublesome line like this is very frustrating, so I’m trying to find a way to prevent Android’s code from catching every exception during development.
My searches online have yielded no information as to how I go about doing this, so I decided to ask here.
Here is the stack trace before the exception is thrown in my code:
Thread [<1> main] (Suspended
(breakpoint at line 72 in GameView))
GameView.showMenu() line: 72
GameView.init() line: 59
GameView.(Context,
AttributeSet) line: 51
Constructor.constructNative(Object[],
Class, Class[], int, boolean) line:
not available [native method]
Constructor.newInstance(Object…)
line: 415
PhoneLayoutInflater(LayoutInflater).createView(String,
String, AttributeSet) line: 505
PhoneLayoutInflater(LayoutInflater).createViewFromTag(String,
AttributeSet) line: 570
PhoneLayoutInflater(LayoutInflater).rInflate(XmlPullParser,
View, AttributeSet) line: 623
PhoneLayoutInflater(LayoutInflater).inflate(XmlPullParser,
ViewGroup, boolean) line: 408
PhoneLayoutInflater(LayoutInflater).inflate(int,
ViewGroup, boolean) line: 320
PhoneLayoutInflater(LayoutInflater).inflate(int,
ViewGroup) line: 276
PhoneWindow.setContentView(int) line:
207
MainActivity(Activity).setContentView(int)
line: 1657
MainActivity.onCreate(Bundle) line:
20
Instrumentation.callActivityOnCreate(Activity,
Bundle) line: 1047
ActivityThread.performLaunchActivity(ActivityThread$ActivityClientRecord,
Intent) line: 1586
ActivityThread.handleLaunchActivity(ActivityThread$ActivityClientRecord,
Intent) line: 1638
ActivityThread.access$1500(ActivityThread,
ActivityThread$ActivityClientRecord,
Intent) line: 117
ActivityThread$H.handleMessage(Message)
line: 928
ActivityThread$H(Handler).dispatchMessage(Message)
line: 99 Looper.loop() line: 123
ActivityThread.main(String[]) line:
3647 Method.invokeNative(Object,
Object[], Class, Class[], Class, int,
boolean) line: not available [native
method] Method.invoke(Object,
Object…) line: 507
ZygoteInit$MethodAndArgsCaller.run()
line: 839 ZygoteInit.main(String[])
line: 597 NativeStart.main(String[])
line: not available [native method]
and here is the stack trace after Eclipse has stopped execution on account of the exception:
Thread [<1> main] (Suspended
(exception RuntimeException))
ActivityThread.performLaunchActivity(ActivityThread$ActivityClientRecord,
Intent) line: 1622
ActivityThread.handleLaunchActivity(ActivityThread$ActivityClientRecord,
Intent) line: 1638
ActivityThread.access$1500(ActivityThread,
ActivityThread$ActivityClientRecord,
Intent) line: 117
ActivityThread$H.handleMessage(Message)
line: 928
ActivityThread$H(Handler).dispatchMessage(Message)
line: 99 Looper.loop() line: 123
ActivityThread.main(String[]) line:
3647 Method.invokeNative(Object,
Object[], Class, Class[], Class, int,
boolean) line: not available [native
method] Method.invoke(Object,
Object…) line: 507
ZygoteInit$MethodAndArgsCaller.run()
line: 839 ZygoteInit.main(String[])
line: 597 NativeStart.main(String[])
line: not available [native method]
Any help would be highly appreciated.
When the debugger breaks like that, just continue execution (probably you’ll need to do this 2 or 3 times). Then look at the LogCat output for a meaningful stack trace.