Eclipse的调试Android应用程序

编程入门 行业动态 更新时间:2024-10-20 07:49:18
本文介绍了Eclipse的调试Android应用程序 - 调试器显示错误的行执行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

而在我的应用程序执行Twitter的整合,我发现Eclipse调试器下面奇怪。是什么原因造成的?

While implementing Twitter integration in my app, I discovered the following oddness of the Eclipse debugger. What is causing this?

我使用这个AsyncTask的使用twitter4j 3.0.3从Twitter获得一个请求令牌。

I'm using this AsyncTask for getting a request token from twitter using twitter4j 3.0.3.

public class TwitterRequestAsync extends AsyncTask<Void, Void, RequestToken> { private Context context; public TwitterRequestAsync(Context context) { this.context = context; } @Override protected RequestToken doInBackground( Void... params ) { Twitter twitter = getTwitter(); // getTwitter() is in enclosing class try { RequestToken token = twitter.getOAuthRequestToken(); return token; } catch (TwitterException e) { Log.e( TAG, e.getMessage(), e ); return null; } } @Override protected void onPostExecute( RequestToken result ) { super.onPostExecute( result ); if ( result != null ) { // stuffs concerning request token here } } }

当我调试这个code,似乎有getOAuthRequestToken()执行时抛出一个异常,下一行,调试器显示执行的是catch子句中,返回null;

When I debug this code it appears that there is an exception thrown when getOAuthRequestToken() executes and the next line that the debugger shows executing is in the catch clause, return null;

然而,返回给onPostExecute(...)的结果是一个有效的请求令牌,所以调试器做一些奇怪的。我清理我的项目,每个多次在这一行为没有变化重新启动Eclipse的。我是不是坏了?

However, the result that is returned to onPostExecute(...) is a valid request token, so the debugger is doing something weird. I've cleaned my project and restarted Eclipse each multiple times with no change in this behavior. Am I broken?

推荐答案

这是一个已知的问题。看来,它可能是与Dalvik虚拟机中的问题。该方法的最后一个返回语句显示在调试器来执行

This is a known issue. It appears that it could be a problem with the Dalvik VM. The last return statement of the method is shown to execute in the debugger.

更改doInBackground身体:

Changing the doInBackground body to:

@Override protected RequestToken doInBackground( Void... params ) { Twitter twitter = getTwitter(); RequestToken token = null; try { token = twitter.getOAuthRequestToken(); } catch (TwitterException e) { Log.e( TAG, e.getMessage(), e ); } return token; }

使执行出现继续如预期。

Causes execution to appear to proceed as expected.

请参阅的groups.google/forum/?fromgroups=#!topic/android-developers/DEU6JmdyFyM对于一个老提这个问题的一个链接到一个更老的提及。终于有人创造了这一个问题在 https://开头code.google / p /安卓/问题/细节?ID = 34193 。

See groups.google/forum/?fromgroups=#!topic/android-developers/DEU6JmdyFyM for an old mention of the problem with a link to an even older mention. Someone finally created an issue for this at code.google/p/android/issues/detail?id=34193.

更多推荐

Eclipse的调试Android应用程序

本文发布于:2023-11-28 16:37:44,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1643160.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:应用程序   Eclipse   Android

发布评论

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

>www.elefans.com

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