gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-11-29 18:15:13 25 4
gpt4 key购买 nike

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

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

界面是这样的:

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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com