Installing plugins
Browse repositories, Plugins, Settings, File--Kotlin
Gradle adding dependencies
Module 'sbuild.gradle
Apply plugin: ' com.android.application ' Apply plugin: ' kotlin-android ' Apply plugin: ' Kotlin-android-extensions ' Android {compilesdkversion buildtoolsversion "25.0.2" defaultconfig {ApplicationID "Com.lxs.kotlincon Fig "Minsdkversion targetsdkversion Versioncode 1 Versionname" 1.0 "testinstrumen Tationrunner "Android.support.test.runner.AndroidJUnitRunner"} buildtypes {release {minifyenabl Ed false Proguardfiles Getdefaultproguardfile (' proguard-android.txt '), ' Proguard-rules.pro '}}}depen dencies {Compile filetree (dir: ' Libs ', include: [' *.jar ']) androidtestcompile (' Com.android.support.test.espresso:es presso-core:2.2.2 ', {Exclude group: ' Com.android.support ', module: ' Support-annotations '}) Compile ' Com.and roid.support:appcompat-v7:25.3.1 ' compile ' com.android.support.constraint:constraint-layout:1.0.2 ' testCompile ' Junit:junit:4.12 '
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 'sbuild.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 Incremental compilation mechanism, can speed up the compilation speed of the project root directory in the gradle.properties configuration
Convert Java code to Kotlin code
Code--Convert Java file to Kotlin file
Shortcut key Ctrl+alt+shift+k
or ctrl+shift+a input convert Java file to Kotlin file
Androidstudio Kotlin Configuration