android - Kotlin 中 Unresolved 函数 'until' 引用

标签 android kotlin android-gradle-plugin

我正在尝试将 Java 项目转换为 Kotlin。我得到一个非常奇怪的编译时错误函数直到 是一个“ Unresolved reference ”,这个函数怎么来的直到 不承认?

 fun renderChildrenToRight(canvas: Canvas, startIndex: Int, stopIndex: Int) {
    val itemRight = nodePosition!!.x + nodeRectLimits.right
    val itemExternalPaddingWidth = getRenderAttribute(AttributeExternalPaddingWidth, AttributeDefaultExternalPadding)
    val itemTop = nodePosition!!.y + nodeRectLimits.top
    val itemExternalPaddingHeight = getRenderAttribute(AttributeExternalPaddingHeight, AttributeDefaultExternalPadding)
    val childItemsSize = getChildItemsSize(startIndex, stopIndex)
    var nextItemTop = itemTop + childItemsSize / 2
    val x = itemRight + itemExternalPaddingWidth


    for (i in startIndex until stopIndex) {
        val currentNode = _children[i]
        val bulletDesiredHeight = currentNode.desiredHeightWithChildren
        val y = nextItemTop - bulletDesiredHeight / 2
        currentNode.setNodePosition(x, y)


        currentNode.renderWithChildren(canvas, BulletRenderStyle.ToTheRight)
        nextItemTop -= bulletDesiredHeight + itemExternalPaddingHeight
    }
}

这是我的旧 Java 方法:
 public void renderChildrenToRight(Canvas canvas, int startIndex, int stopIndex) {
        int itemRight = getNodePosition().x + getNodeRectLimits().right;
        int itemExternalPaddingWidth = getRenderAttribute(AttributeExternalPaddingWidth, AttributeDefaultExternalPadding);
        int itemTop = getNodePosition().y + getNodeRectLimits().top;
        int itemExternalPaddingHeight = getRenderAttribute(AttributeExternalPaddingHeight, AttributeDefaultExternalPadding);
        int childItemsSize = getChildItemsSize(startIndex, stopIndex);
        int nextItemTop = itemTop + childItemsSize / 2;
        int x = itemRight + itemExternalPaddingWidth;


        for (int i = startIndex; i < stopIndex; i++) {
            Node currentNode = _children.get(i);
            int bulletDesiredHeight = currentNode.getDesiredHeightWithChildren();
            int y = nextItemTop - bulletDesiredHeight / 2;
            currentNode.setNodePosition(x, y);


            currentNode.renderWithChildren(canvas, BulletRenderStyle.ToTheRight);
            nextItemTop -= bulletDesiredHeight + itemExternalPaddingHeight;
        }

最佳答案

您的 Intellij IDEA 插件和您在项目中使用的 Kotlin 运行时/编译器需要匹配。您的 android studio 必须升级为支持 kotlin。检查所有这些并重新启动您的 android studio。

关于android - Kotlin 中 Unresolved 函数 'until' 引用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53992611/

相关文章:

android - CircleCI Android构建因Gradle 6.4失败

android - Android + Kotlin 中的实验性 JUnit 支持不起作用

android - 花很多时间建立gradle

kotlin - 如何习惯性地在Kotlin中调用可为空的Lambda?

android - google-service.json 现在是强制性的吗?

Android Realm 版本升级错误与 gradle

android - 发现多个文件具有独立于操作系统的路径 'AndroidManifest.xml'

android - 无法在 android studio 的屏幕上显示和保存捕获的图像

android - 如何确定联系人数据库中的哪一行已更新

kotlin - 如何在 Kotlin 中为多个变量分配相同的值