如何调试ExceptionInInitializationError?
我在一个非常简单的“研究”应用程序中遇到异常,所以我希望问题出在我的项目设置中,但我不知道如何调试...
异常“ExceptionInInitializationError”的上下文是什么?
它记录在哪里?答:从 Eclipse 调试器中搜索 Android 开发人员指南
堆栈跟踪:选择线程 ->右键单击->复制堆栈
Thread [<3> main] (Suspended (exception ExceptionInInitializerError))
Class.newInstance() line: 1479
Instrumentation.newActivity(ClassLoader, String, Intent) line: 1021
ActivityThread.performLaunchActivity(ActivityThread$ActivityRecord, Intent) line: 2367
ActivityThread.handleLaunchActivity(ActivityThread$ActivityRecord, Intent) line: 2470
ActivityThread.access$2200(ActivityThread, ActivityThread$ActivityRecord, Intent) line: 119
ActivityThread$H.handleMessage(Message) line: 1821
ActivityThread$H(Handler).dispatchMessage(Message) line: 99
Looper.loop() line: 123
ActivityThread.main(String[]) line: 4310
Method.invokeNative(Object, Object[], Class, Class[], Class, int, boolean) line: not available [native method]
Method.invoke(Object, Object...) line: 521
ZygoteInit$MethodAndArgsCaller.run() line: 860
ZygoteInit.main(String[]) line: 618
NativeStart.main(String[]) line: not available [native method]
这是 logcat:
I/ActivityManager( 52): Starting activity: Intent { flg=0x10000000 cmp=com.androidcode.study_wikinotes/.WikiNotes }
D/AndroidRuntime( 198): Shutting down VM
D/dalvikvm( 198): DestroyJavaVM waiting for non-daemon threads to exit
D/dalvikvm( 198): DestroyJavaVM shutting VM down
D/dalvikvm( 198): HeapWorker thread shutting down
D/dalvikvm( 198): HeapWorker thread has shut down
D/jdwp ( 198): JDWP shutting down net...
I/jdwp ( 198): adbd disconnected
D/dalvikvm( 198): VM cleaning up
E/AndroidRuntime( 198): ERROR: thread attach failed
I/ActivityManager( 52): Start proc com.androidcode.study_wikinotes for activity com.androidcode.study_wikinotes/.WikiNotes: pid=219 uid=10023 gids={}
D/dalvikvm( 198): LinearAlloc 0x0 used 634508 of 5242880 (12%)
D/ddm-heap( 155): Got feature list request
D/ddm-heap( 169): Got feature list request
D/ddm-heap( 183): Got feature list request
D/ddm-heap( 206): Got feature list request
D/ddm-heap( 219): Got feature list request
W/ActivityThread( 219): Application com.androidcode.study_wikinotes is waiting for the debugger on port 8100...
I/System.out( 219): Sending WAIT chunk
I/dalvikvm( 219): Debugger is active
I/System.out( 219): Debugger has connected
I/System.out( 219): waiting for debugger to settle...
I/System.out( 219): waiting for debugger to settle...
I/System.out( 219): waiting for debugger to settle...
I/System.out( 219): waiting for debugger to settle...
I/System.out( 219): waiting for debugger to settle...
I/System.out( 219): waiting for debugger to settle...
I/System.out( 219): waiting for debugger to settle...
I/System.out( 219): waiting for debugger to settle...
I/System.out( 219): waiting for debugger to settle...
I/System.out( 219): waiting for debugger to settle...
I/System.out( 219): waiting for debugger to settle...
I/System.out( 219): debugger has settled (1382)
W/dalvikvm( 219): Exception Ljava/util/regex/PatternSyntaxException; thrown during Lcom/androidcode/study_wikinotes/WikiNotes;.<clinit>
W/dalvikvm( 219): Class init failed in newInstance call (Lcom/androidcode/study_wikinotes/WikiNotes;)
啊...我在 WikiNotes 中有一个不完整的类。你会说答案是“从 logcat 开始”吗? :) 感谢您的帮助。继续添加您的答案,我会接受它。
I am getting an exception in a very simple 'study' application, so I expect the problem to be in my project setup, but I don't know how to debug ...
What is the context of the exception, "ExceptionInInitializationError"?
Where is it documented? A: Search Android Developers Guide
Stack trace from within Eclipse Debugger with: select thread -> right-click -> copy stack
Thread [<3> main] (Suspended (exception ExceptionInInitializerError))
Class.newInstance() line: 1479
Instrumentation.newActivity(ClassLoader, String, Intent) line: 1021
ActivityThread.performLaunchActivity(ActivityThread$ActivityRecord, Intent) line: 2367
ActivityThread.handleLaunchActivity(ActivityThread$ActivityRecord, Intent) line: 2470
ActivityThread.access$2200(ActivityThread, ActivityThread$ActivityRecord, Intent) line: 119
ActivityThread$H.handleMessage(Message) line: 1821
ActivityThread$H(Handler).dispatchMessage(Message) line: 99
Looper.loop() line: 123
ActivityThread.main(String[]) line: 4310
Method.invokeNative(Object, Object[], Class, Class[], Class, int, boolean) line: not available [native method]
Method.invoke(Object, Object...) line: 521
ZygoteInit$MethodAndArgsCaller.run() line: 860
ZygoteInit.main(String[]) line: 618
NativeStart.main(String[]) line: not available [native method]
Here is the logcat:
I/ActivityManager( 52): Starting activity: Intent { flg=0x10000000 cmp=com.androidcode.study_wikinotes/.WikiNotes }
D/AndroidRuntime( 198): Shutting down VM
D/dalvikvm( 198): DestroyJavaVM waiting for non-daemon threads to exit
D/dalvikvm( 198): DestroyJavaVM shutting VM down
D/dalvikvm( 198): HeapWorker thread shutting down
D/dalvikvm( 198): HeapWorker thread has shut down
D/jdwp ( 198): JDWP shutting down net...
I/jdwp ( 198): adbd disconnected
D/dalvikvm( 198): VM cleaning up
E/AndroidRuntime( 198): ERROR: thread attach failed
I/ActivityManager( 52): Start proc com.androidcode.study_wikinotes for activity com.androidcode.study_wikinotes/.WikiNotes: pid=219 uid=10023 gids={}
D/dalvikvm( 198): LinearAlloc 0x0 used 634508 of 5242880 (12%)
D/ddm-heap( 155): Got feature list request
D/ddm-heap( 169): Got feature list request
D/ddm-heap( 183): Got feature list request
D/ddm-heap( 206): Got feature list request
D/ddm-heap( 219): Got feature list request
W/ActivityThread( 219): Application com.androidcode.study_wikinotes is waiting for the debugger on port 8100...
I/System.out( 219): Sending WAIT chunk
I/dalvikvm( 219): Debugger is active
I/System.out( 219): Debugger has connected
I/System.out( 219): waiting for debugger to settle...
I/System.out( 219): waiting for debugger to settle...
I/System.out( 219): waiting for debugger to settle...
I/System.out( 219): waiting for debugger to settle...
I/System.out( 219): waiting for debugger to settle...
I/System.out( 219): waiting for debugger to settle...
I/System.out( 219): waiting for debugger to settle...
I/System.out( 219): waiting for debugger to settle...
I/System.out( 219): waiting for debugger to settle...
I/System.out( 219): waiting for debugger to settle...
I/System.out( 219): waiting for debugger to settle...
I/System.out( 219): debugger has settled (1382)
W/dalvikvm( 219): Exception Ljava/util/regex/PatternSyntaxException; thrown during Lcom/androidcode/study_wikinotes/WikiNotes;.<clinit>
W/dalvikvm( 219): Class init failed in newInstance call (Lcom/androidcode/study_wikinotes/WikiNotes;)
Ahh ... I have an incomplete class in WikiNotes. Would you say the answer is to "start with logcat"? :) Thanks for the help. Go ahead and add your answer and I will accept it.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
是的,在 Android 中进行调试时要做的第一件事是首先查看 LogCat。
Yes the first thing to do when debugging in Android is to start by looking in LogCat.