AndroidStudio kotlin配置詳細(xì)介紹
AndroidStudio kotlin配置
安裝插件
File -> Settings -> Plugins -> Browse repositories -> 搜索 kotlin
gradle添加依賴(lài)
Module的build.gradle
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "com.lxs.kotlinconfig"
minSdkVersion 15
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
testCompile 'junit:junit:4.12'<br>
compile "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
compile "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"
}
repositories {
maven {url 'http://maven.aliyun.com/nexus/content/groups/public/'}
}
Project的build.gradle
buildscript {
ext.kotlin_version = '1.1.2-4'
repositories {
maven {url 'http://maven.aliyun.com/nexus/content/groups/public/'}
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.2'
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 {
maven {url 'http://maven.aliyun.com/nexus/content/groups/public/'}
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
kotlin.incremental=true增量編譯的機(jī)制,可以加快編譯速度 項(xiàng)目根目錄的gradle.properties里配置
把Java代碼轉(zhuǎn)換成kotlin代碼
Code -> Convert Java File to Kotlin File
快捷鍵 ctrl+alt+shift+k
或者ctrl+shift+A 輸入Convert Java File to Kotlin File
感謝閱讀,希望能幫助到大家,謝謝大家對(duì)本站的支持!
- Android Kotlin的使用及簡(jiǎn)單實(shí)例
- Kotlin開(kāi)發(fā)Android應(yīng)用實(shí)例詳解
- 使用Kotlin開(kāi)發(fā)Android應(yīng)用教程
- 五分鐘教你Android-Kotlin項(xiàng)目編寫(xiě)
- Android開(kāi)發(fā)必備知識(shí) 為什么說(shuō)Kotlin值得一試
- 如何使用Kotlin進(jìn)行Android開(kāi)發(fā)
- Android中使用Kotlin實(shí)現(xiàn)一個(gè)簡(jiǎn)單的登錄界面
- Kotlin在Android工程中的應(yīng)用詳解
- 利用Kotlin開(kāi)發(fā)你的第一個(gè)Android應(yīng)用
- Android動(dòng)畫(huà)入門(mén)教程之kotlin
相關(guān)文章
Android中 webView調(diào)用JS出錯(cuò)的解決辦法
這篇文章主要介紹了Android中 webView調(diào)用JS出錯(cuò)的解決辦法,需要的朋友可以參考下2015-01-01
Android?Recyclerview實(shí)現(xiàn)左滑刪除功能
這篇文章主要為大家詳細(xì)介紹了Android?Recyclerview實(shí)現(xiàn)左滑刪除功能,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2022-04-04
anndroid使用ViewPager實(shí)現(xiàn)三個(gè)fragment切換
這篇文章主要介紹了anndroid使用ViewPager實(shí)現(xiàn)三個(gè)fragment切換,小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧2018-04-04
Android開(kāi)源框架的SlidingFragment的使用示例
今天小編就為大家分享一篇關(guān)于Android開(kāi)源框架的SlidingFragment的使用示例,小編覺(jué)得內(nèi)容挺不錯(cuò)的,現(xiàn)在分享給大家,具有很好的參考價(jià)值,需要的朋友一起跟隨小編來(lái)看看吧2019-03-03
解決android studio 打包發(fā)現(xiàn)generate signed apk 消失不見(jiàn)問(wèn)題
這篇文章主要介紹了解決android studio 打包發(fā)現(xiàn)generate signed apk 消失不見(jiàn)問(wèn)題,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧2020-09-09
Android自定義控件實(shí)現(xiàn)九宮格解鎖功能
這篇文章主要為大家詳細(xì)介紹了Android自定義控件實(shí)現(xiàn)九宮格解鎖功能,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2017-05-05
Android RecyclerView的刷新分頁(yè)的實(shí)現(xiàn)
這篇文章主要介紹了Android RecyclerView的刷新分頁(yè)的實(shí)現(xiàn),小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧2018-05-05
Android文字匹配度算法及實(shí)際應(yīng)用示例
本文介紹了Android應(yīng)用中常用的文字匹配度算法Levenshtein Distance,并給出了實(shí)際應(yīng)用示例,通過(guò)合理選擇和應(yīng)用文字匹配度算法,可以實(shí)現(xiàn)多種功能,提升用戶(hù)體驗(yàn),增強(qiáng)應(yīng)用的實(shí)用性,需要的朋友可以參考下2024-05-05
深入解析Android App開(kāi)發(fā)中Context的用法
這篇文章主要介紹了深入解析Android App開(kāi)發(fā)中Context的用法,包括Context的創(chuàng)建場(chǎng)景和Context對(duì)資源的訪問(wèn)等內(nèi)容,需要的朋友可以參考下2016-02-02

