环境:AS3.0开发
默认创建一个Application,Include KotLin support
可能运行失败,可参考官网配置:
https://github.com/wangjiegulu/kotlin-for-android-developers-zh/blob/master/pei_zhi_gradle.md
主要如下:
父build文件:
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()
}
}
子build配置:
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"
}
}
在最新as3.0中存在bug:
Error:Unable to find method 'com.android.build.gradle.internal.variant.BaseVariantData.getOutputs()L
解决方案:
ext.kotlin_version = ‘1.1.2-3’ 换成: ext.kotlin_version = ‘1.1.2-4’