【问题标题】:Android Studio jumping over breakpointsAndroid Studio 跳过断点
【发布时间】:2017-04-10 04:43:33
【问题描述】:

我遇到了 Android Studio 跳过我的断点的问题。我以前没有遇到过这个问题,最近才开始发生。

我在没有外来插件的 MAC 上运行 Android Studio 2.3.1。有任何想法吗?代码如下:

private fun getLatestZip(): File? {
        var fileName = context.fileList().find { it.toUpperCase().contains("MBTA_GTFS") }
        var dateTime = getGftsTimestamp()
        var file: File?
        if (dateTime == null) {
            file = downloadLatestGfts() // skips the break on this line
            if (file != null) {
                printGftsTimestamp()
            }
            else {
                Timber.e("Failed to download Gfts") // and goes straight to here
            }
        } else if (!fileName.isNullOrEmpty()) {....

编辑—— 这是一个视频,可以准确地向您展示正在发生的事情。这可能是 kotlin 的问题。 https://youtu.be/fJOIzD8ckv8

【问题讨论】:

  • 看起来很像源代码和编译代码之间的不匹配。您可以尝试将顶层和应用程序构建文件夹重命名为 build.old 以强制重建所有内容。当工作室感到困惑(或者我确实如此)时,我发现这会有所帮助。

标签: android android-studio kotlin


【解决方案1】:

您需要在 downloadLatestGfts() 函数中放置断点或按 F8 转到下一行(即文件 null 检查 if 语句)。

【讨论】:

  • 我正在按 f8 跳过该功能。我什至在downloadLatestGfts() 函数中设置了断点。
【解决方案2】:

尝试运行代码,在该行设置断点

if (dateTime == null)

并检查 dateTime 的值是否为空。可能是因为那个 null 值,所以控件直接进入 else 条件。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-10-13
    • 2018-09-09
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多