在AS中使用Gradle配置,如下修改父build.gradle:
buildscript {
ext.support_version = '23.1.1'
ext.kotlin_version = '1.0.0'
ext.anko_version = '0.8.2'
repositories {
jcenter()
dependencies {
classpath 'com.android.tools.build:gradle:1.5.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
}
allprojects {
repositories {
jcenter()
}
}
增加Kotlin标准库,Anko库,以及Kotlin和Kotlin Android Extensions plugin插件到dependencies:
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
android {
...
}
dependencies {
compile "com.android.support:appcompat-v7:$support_version"
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
compile "org.jetbrains.anko:anko-common:$anko_version"
}
buildscript {
repositories {
jcenter()
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-android-extensions:$kotlin_version"
}
}