Android Studio 集成Kotlin遇到的错误

1.Error:Execution failed for task ‘:app:compileDebugKotlin’

Error:Execution failed for task ':app:compileDebugKotlin'. > Compilation error. See log for more details

   
   
  • 1

多的不说,旨在解决问题

首先你需要确认你的配置写的是否完整

参考官方文档

https://kotlinlang.org/docs/tutorials/kotlin-android.html

1)、module.build中添加

apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'

dependencies {
    compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
}

  
  
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6

2)、project.build中添加

    buildscript {
    //添加
    ext.kotlin_version = "1.1.51"

    repositories {
        jcenter()
        maven { url "https://jitpack.io" }
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.0.1'
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files

        //添加
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        classpath "org.jetbrains.kotlin:kotlin-android-extensions:$kotlin_version"
    }
}
[原文地址](https://blog.csdn.net/qq_26761229/article/details/78865513)

发布了59 篇原创文章 · 获赞 13 · 访问量 3万+

猜你喜欢

转载自blog.csdn.net/Hunter2916/article/details/97103601