Kotlin is a new programming language Developed by JetBrains.
This article about
1.How to configure Kotlin plugin to Android Studio.
2. Create Hollo world App.
Install Kotlin Plugin to Android Studio
File -> Settings -> Plugins - > Browse Repositories -> Search -> Kotlin -> Install
Create new Android Project and Apply Kotlin Plugin to your project.
Apply Kotlin to your project
Convert Activity java code to Kotlin
This is java code
This article about
1.How to configure Kotlin plugin to Android Studio.
2. Create Hollo world App.
Install Kotlin Plugin to Android Studio
File -> Settings -> Plugins - > Browse Repositories -> Search -> Kotlin -> Install
Create new Android Project and Apply Kotlin Plugin to your project.
Apply Kotlin to your project
buildscript {
ext.kotlin_version = "1.0.6" // replace with the latest (stable) version: https://github.com/JetBrains/kotlin/releases/latest
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.3'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android' // apply kotlin android plugin
Convert Activity java code to Kotlin
This is java code
package world.hello.kotlin.kotlinfirstproject; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; public class MainActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); } }
After Conversion
package world.hello.kotlin.kotlinfirstproject import android.support.v7.app.AppCompatActivity import android.os.Bundle class MainActivity : AppCompatActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_main) } }