Kotlin 學(xué)習(xí)地址總結(jié)
1 . 官網(wǎng)教程
2 . Anko GitHub
3 . Kotlin Resource
android studio 配置
1 . 當(dāng)前項(xiàng)目的build.gradle
ext.support_version = '23.1.1'//添加
ext.kotlin_version = '1.0.4'//添加
ext.anko_version = '0.10.1'//添加
repositories {
// jcenter() 更改為
maven{ url 'http://maven.aliyun.com/nexus/content/groups/public'}
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"http://添加
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
// jcenter() 更改為
maven{ url 'http://maven.aliyun.com/nexus/content/groups/public'}
maven {url 'https://dl.bintray.com/jetbrains/anko'}//添加
}
}
2 . module的build.gradle
中的dependencies {}
下添加以下依賴
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
compile "com.android.support:appcompat-v7:$support_version"
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
compile "org.jetbrains.anko:anko-common:$anko_version"
compile "org.jetbrains.anko:anko-appcompat-v7-listeners:$anko_version"
compile "org.jetbrains.anko:anko-design-listeners:$anko_version"
compile "org.jetbrains.anko:anko-design:$anko_version"
compile "org.jetbrains.anko:anko-sdk15-listeners:$anko_version"
compile "org.jetbrains.anko:anko-sdk15:$anko_version"
compile "org.jetbrains.anko:anko-recyclerview-v7:$anko_version"
Kotlin問題
- 出現(xiàn)Gradle DSL not fund Method問題
compile "org.jetbrains.anko:anko-recyclerview-v7:$anko_version" compile 'com.android.support:appcompat-v7:25.3.1'
更改為:
compile "org.jetbrains.anko:anko-recyclerview-v7:$anko_version"
compile 'com.android.support:appcompat-v7:25.3.1'
不確定,為什么一定要換行才行桅打?
切記切記!!该溯!
compile "....$..."
這個(gè)語法必須要buildtoolsVerision大于26.0.1才支持
- 關(guān)于
build.gradle
文件中一些變量解釋
compileSdkVersion 25 //當(dāng)前編譯的sdk
buildToolsVersion "25.0.2"http://構(gòu)建工程包括 compile等等的工具 必須大于 compileSdkVersion
defaultConfig {
applicationId "adr.ycx.com.testsreen"
minSdkVersion 21 //最低版本 lint在我們寫代碼時(shí)會(huì)提示當(dāng)前api是否滿足最低版本
targetSdkVersion 25// 最高版本 一般來說要等于compileVersion 不能大于它
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
java和kotlin互相調(diào)用的總結(jié)
1 . j use k 類與方法