Create Your First Android Project with Kotlin

Building Android apps with Kotlin is as simple as selecting an option when creating a project. For this you need Android Studio 3.0.

Create a Kotlin Project:

1) Start a new project as you usually you do with Android Studio.

2) Here in the Create New Project window, you have to select the Include Kotlin Support option at the bottom.

Create a New Kotlin Project

3) The rest of the steps (selecting the SDK version, Selecting your starter activity and customizing it) remains the same.

Select Android SDK

Select Starter Activity

Customize Activity

4) Finally, click finish to create your first Kotlin project.

Basic Kotlin Project

Changes happened compared to Java project:

1) Instead of creating MainActivity.java, the IDE now creates MainActivity.kt file.

2) kotlin-android, kotlin-android-extensions plugins and appropriate dependency were added to the module level build.gradle file.

apply plugin: 'kotlin-android'

apply plugin: 'kotlin-android-extensions'

dependencies {
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
}

3) A classpath was added to the project level build.gradle file

classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version

Now, explore the code in the MainActivity.kt and draw comparisons with the MainActivity.java. In the upcoming tutorials, we will familiarize ourselves with Kotlin by writing the code.

Popular posts from this blog

Create Assets Folder, Add Files and Read Data From It

How to Read Metadata from AndriodManifest File

Add Spacing to Recycler View Linear Layout Manager Using Item Decoration

Run the Emulator directly in Android Studio

How to Change Material Chip Text Size, Text Style and Font