Androidstudio Kotlin Configuration

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.