Trying to start a new Kotlin project with Android Studio 3.0 Canary 1 displays this error. Full trace:

错误:找不到方法

  • Gradle's dependency cache may be corrupt (this sometimes occurs after a network connection timeout.) Re-download dependencies and sync project (requires network)
  • The state of a Gradle build process (daemon) may be corrupt. Stopping all Gradle daemons may solve this problem. Stop Gradle build processes (requires restart)
  • 您的项目可能正在使用
In the case of corrupt Gradle processes, you can also try closing the IDE and then killing all Java processes.

I've tried the first two options and the third-party plugins are left as default.

gradle-wrapper.properties

#Thu May 18 08:36:52 BST 2017
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.0-milestone-1-all.zip

build.gradle

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    ext.kotlin_version = '1.1.2-3'
    repositories {
        maven { url 'https://maven.google.com' }
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.0.0-alpha1'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        jcenter()
        maven { url 'https://maven.google.com' }
        mavenCentral()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

我自己没有碰过这些值,它们是默认值.创建一个非Kotlin的新项目没有这个问题.

推荐答案

在我的百变中

ext.kotlin_version = '1.1.2-3'

ext.kotlin_version = '1.1.2-4'

解决了这个问题.

您可以找到最新的版本here.

Kotlin相关问答推荐

将Kotlin中的函数变量委托给通用类

Kotlin 海峡没有结束

Java/Kotlin中类似Rust般的注释编译?

Ktor 在 Heroku 上的 CORS 问题,但在本地没有

如何在 Spring Boot 3 中为内部类提供运行时提示

Kotlin 函数有 2 个参数用于对 Map 或 List 进行排序

通用接口继承

具有泛型类型的 Kotlin 密封接口不会为其子类型推断约束

如何缩短 MaterialTheme.colors.primary?

使用 Hilt 注入 CoroutineWorker

IntelliJ 不会根据 ktlint 的期望对 Kotlin 导入进行排序

验证和 DDD - kotlin 数据类

什么是开放式property?为什么我不能将其设置器设为private私有?

Kotlin协程处理错误和实现

未找到导入 kotlinx.coroutines.flow.*

生成Kotlin类图

Kotlin中的Memoization功能

在 kotlin 中,如何将主构造函数中的属性设置器设为私有?

在 Kotlin 中声明 Byte 会出现编译时错误The integer literal does not conform to the expected type Byte

Dagger 2 androidx fragment不兼容类型