android - 静态最终变量在 Debug模式下显示为 null 和 0.0

标签 android eclipse debugging interface constants

我正在 Debug模式下运行 Android 应用程序,其中有一些常量定义为位于 Interface 中的 static Final 变量。

当我在 Eclipse 中处于 Debug模式时,将鼠标悬停在这些常量上以查看其内容,我看到字符串为 null, double 为 0.0

界面如下所示:

public interface IMyConstants {
    public static double DOUBLE_CONST = 4.2235234;
    public static String STRING_CONST= "Should be some string";
}

此接口(interface)位于类路径中包含的外部非 Android 项目中。

来自其他引用的 Android 项目的其他常量似乎向我提供了它们的信息,并且它们的声明方式完全相同。

我想知道调试器是否很难阅读这些内容,因为该项目不是 Android,因为这是我最初能看到的唯一区别。

就在断点之前,我确实将常量 DOUBLE_CONST 的值输出到 LogCat,并得到了正确的值。

这个:

// Hovering over any of the constants here do not show their true value in debug

double value = myValue / IMyConstants.DOUBLE_CONST; 
Log.i("MyProject", "IMyConstants.DOUBLE_CONST: " + IMyConstants.DOUBLE_CONST);
Log.i("MyProject", "IMyConstants.STRING_CONST: " + IMyConstants.STRING_CONST);

/*
 * The breakpoint is here.. 
 * hovering over DOUBLE_CONST above shows DOUBLE_CONST = 0.0
 * hovering over STRING_CONST above shows STRING_CONST = null
 */
someBreakPointedMethod();  

给出:

12-19 23:32:54.316: INFO/MyProject(23806): IMyConstants.DOUBLE_CONST: 4.2235234
12-19 23:32:54.316: INFO/MyProject(23806): IMyConstants.STRING_CONST: Should be some string

为什么调试对象 View (将鼠标悬停在变量上时弹出的 View )在这种情况下不起作用?

最佳答案

只需将断点放在语句后面即可 像这样

  • 将鼠标悬停在上面的 DOUBLE_CONST 上会显示 DOUBLE_CONST = 0.0
  • 将鼠标悬停在上面的 STRING_CONST 上会显示 STRING_CONST = null

断点应该在这里..

关于android - 静态最终变量在 Debug模式下显示为 null 和 0.0,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8571437/

相关文章:

android - 如何从 Android 应用程序编写 android 二进制 XML?

eclipse - 维护一组通用的 Eclipse 首选项

java - Eclipse:使用 Java Code Formatter 进行 block 式字段对齐

flash - 使用 Flash + AS3 发布/调试配置

c - 如何在C调试中确定多个数字是奇数还是偶数

php - Laravel - 更好的错误跟踪

android - 重复的 jar 条目 - android

android - RelativeLayout 宽度和高度 fill_parent 不起作用

java - SWT 文件夹 '..\framework\x86' 不存在。请设置 ANDROID_SWT 指向包含您平台的 swt.jar 的文件夹

java - Eclipse 出现问题,无法导入 org.apache.maven.surefire.report.RunListener;