1 Creating a new project
Android Studio creates a new project with only one empty mainactivity
2 Installing Kotlin
File-seeting-plugins-install jetbrains Plugin input Kotlin installation,
If the installation fails, open the C:\Users\ user \. Androidstudio2.3\system\log\idea.log "This file, find Kotlin
Http://plugins.jetbrains.com/pluginManager/?action=download&id=org.jetbrains.kotlin&build= ai-162.2228.14&uuid=6b417889-78a8-4cc8-ac6c-3e8d64c5a56c
Download to d:\kotlin-plugin-1.1.1-release-Studio2.3-1.zip with IE single thread
Click Install plugin from disk for installation, then restart Studio
3 Configuration
Apply the following build.gradle to add
ext.kotlin_version = ' 1.1.1 '
Classpath "Org.jetbrains.kotlin:kotlin-gradle-plugin: $kotlin _version"
Add two lines to the Build.gradle in the app folder
Apply plugin: ' kotlin-android '
Apply plugin: ' kotlin-android-extensions '
and compile "Org.jetbrains.kotlin:kotlin-stdlib: $kotlin _version"
4 Convert Mainactivity.java to Mainactivity.kt
5
Activity_main.xml Delete the original TextView, add the following
<textview
Android:id= "@+id/tv"
Android:layout_width= "Wrap_content"
android:layout_height= "Wrap_content"
android:text= "Hello world!"/>
Mainactivity.kt file Additions
Import kotlinx.android.synthetic.main.activity_main.*
Tv.text = "Hello Kotlin"
Tv.textsize = 20.0f
Run!!!!!!!!!!
Have you succeeded?
Develop Android's Hello kotlin!! with Kotlin