我如何prevent异常捕获的Andr​​oid的?

编程入门 行业动态 更新时间:2024-10-10 14:31:40
本文介绍了我如何prevent异常捕获的Andr​​oid的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我试图开发的Andr​​oid应用程序,但我有困难跟踪每个例外,我得到这个过程的来源和成因。 我的code运行在一个活动,如果线路防雷导致异常的话,而不是停在该行,并强调它,它抛出我到A​​ctivityThread类的code,这显然我没有,所以我只是得到一个找不到源代码屏幕。

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.

试图找出麻烦这样一行是非常令人沮丧,所以我试图找到一种方法,prevent Android的code从开发过程中捕捉每一个例外。 我的在线搜索没有取得信息,如何我去这样做,所以我决定在这里问。

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.

下面是异常之前堆栈跟踪被扔在我的code:

Here is the stack trace before the exception is thrown in my code:

主题[< 1>主](暂停   (断点线72 GameView))     GameView.showMenu()线:72     GameView.init()线:59     GameView(背景下,   AttributeSet中)线:51     Constructor.constructNative(对象[],   上课,下课[],INT,布尔)线:   不可用[本地方法]     Constructor.newInstance(对象...)   行:415     PhoneLayoutInflater(LayoutInflater).createView(字符串,   字符串的AttributeSet)线:505     PhoneLayoutInflater(LayoutInflater).createViewFromTag(字符串,   AttributeSet中)线:570     PhoneLayoutInflater(LayoutInflater).rInflate(XmlPullParser,   查看,AttributeSet中)线:623     PhoneLayoutInflater(LayoutInflater).inflate(XmlPullParser,   ViewGroup中,布尔)线:408     PhoneLayoutInflater(LayoutInflater).inflate(INT,   ViewGroup中,布尔)线:320     PhoneLayoutInflater(LayoutInflater).inflate(INT,   ViewGroup中)线:276     PhoneWindow.setContentView(INT)线:   207     MainActivity(活动).setContentView(INT)   行:1657     MainActivity.onCreate(捆绑)线:   20     Instrumentation.callActivityOnCreate(活动,   包)线:1047     ActivityThread.performLaunchActivity(ActivityThread $ ActivityClientRecord,   意图)线:1586     ActivityThread.handleLaunchActivity(ActivityThread $ ActivityClientRecord,   意图)线:1638     ActivityThread.access $ 1500(ActivityThread,   ActivityThread $ ActivityClientRecord,   意图)线:117     ActivityThread $ H.handleMessage(消息)   行:928     ActivityThread $ H(处理器).dispatchMessage(消息)   行:99 Looper.loop()线:123     ActivityThread.main(字符串[])线路:   3647 Method.invokeNative(对象,   [对象],上课,下课[],类,INT,   布尔)行:不可用[本地   法] Method.invoke(对象,   对象...)线:507     ZygoteInit $ MethodAndArgsCaller.run()   行:839 ZygoteInit.main(字符串[])   行:597 NativeStart.main(字符串[])   行:不可用[本地方法]

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]

和这里的Eclipse之后的堆栈跟踪已停止对账户除执行:

and here is the stack trace after Eclipse has stopped execution on account of the exception:

主题[&LT; 1>主](暂停   (RuntimeException的除外))     ActivityThread.performLaunchActivity(ActivityThread $ ActivityClientRecord,   意图)线:1622     ActivityThread.handleLaunchActivity(ActivityThread $ ActivityClientRecord,   意图)线:1638     ActivityThread.access $ 1500(ActivityThread,   ActivityThread $ ActivityClientRecord,   意图)线:117     ActivityThread $ H.handleMessage(消息)   行:928     ActivityThread $ H(处理器).dispatchMessage(消息)   行:99 Looper.loop()线:123     ActivityThread.main(字符串[])线路:   3647 Method.invokeNative(对象,   [对象],上课,下课[],类,INT,   布尔)行:不可用[本地   法] Method.invoke(对象,   对象...)线:507     ZygoteInit $ MethodAndArgsCaller.run()   行:839 ZygoteInit.main(字符串[])   行:597 NativeStart.main(字符串[])   行:不可用[本地方法]

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]

任何帮助将是非常美联社preciated。

Any help would be highly appreciated.

推荐答案

在调试器中断那样,只是继续执行(可能是你需要做2〜3次)。然后看LogCat中输出有意义的堆栈跟踪。

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.

更多推荐

我如何prevent异常捕获的Andr​​oid的?

本文发布于:2023-06-05 22:04:04,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/529888.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:异常   prevent   oid   Andr

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!