Eclipse的调试Android应用程序 - 调试器显示错误的行执行 [英] Eclipse debugging Android app - debugger shows wrong line executing
问题描述
而在我的应用程序执行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.
请参阅的https://groups.google.com/forum/?fromgroups=#!topic/android-developers/DEU6JmdyFyM对于一个老提这个问题的一个链接到一个更老的提及。终于有人创造了这一个问题在 https://开头code.google.com / p /安卓/问题/细节?ID = 34193 。
See https://groups.google.com/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 https://code.google.com/p/android/issues/detail?id=34193.
这篇关于Eclipse的调试Android应用程序 - 调试器显示错误的行执行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!