12

デバッグ (Eclipse) の場合、変数ビュー、式ビュー、表示ビューで変数の内容を表示できません。変数が匿名クラスの外部で定義されているが、デバッグが匿名クラスの内部にある場合です。

デバッグでコンテンツを表示しようとすると、次のエラーが表示されます: x を変数に解決できません

次の例では、x を解決できません。

private void someMethod(final Object x) {
  new Runnable() {
    public void run() {
      Log.i(x); // x is printed correctly but cannot be resolved when in Debug
    }
  }.run();
}

この質問は、Eclipse開発環境に関するものです-Androidのデバッグに関するものです。これは最終的な議論でもコンパイルでもありません - ただのデバッグです。

4

2 に答える 2

2

I have faced similar issues while debugging applications that uses threads. I guess your application is multi-threaded one, because I used to face things like this only at that situation. This could be because when you run the program directly mostly all your threads will be started at the same time. But while in debug mode one of your thread which has the breakpoint set will be holding, where as other threads which started along would have been completed already or the other way around. That's the reason people say debugging a multi threaded application is bit more difficult unless you maintain the priority or make threads synchronized.

Hope this info helps. So instead of stopping the flow with a break point, try to print the value where you need to know the value using sysout or things like that, which is like just running the program but still debugging, your own way:)

于 2014-06-20T04:59:53.100 に答える
0

最近同じ問題が発生しましたが、Android SDKを更新してから、Eclipseを再起動すると修正されました。SDKを最新バージョンに更新してみてください。

于 2012-09-26T02:24:53.323 に答える