Pre-Amble

Kotlin is the hot “new” language for Android development. I say “new” because it’s actually been around for almost a decade, however google have finally adopted it as their pet development language for Android!

If you want to develop in Kotlin then there are 2 options for you:

  • Use IntelliJ or
  • Use Android studio

It doesn’t really matter which one you choose because Android Studio is actually a modified version of IntelliJ, fine tuned for ease of Android development.

Step 1 – Download

Download and install Android Studio from

https://developer.android.com/studio/

Step 2 – Create Kotlin Project

Create a new Android Project and make sure you check “Kotlin Support” during the wizard setup process.

Step 3 – Wait a Bit

Leave the remaining options as default and let Android Studio set everything up for you.

 

Step 4 – It’s a Bit Different in Here

Here’s the code you’ll be faced with in the MainActivity.kt file:

First off, we no longer have the @ symbol that is ever present in Java. Also note the inheritance syntax is different too:

Recall that in Java we would have had:

Step 5 – Write a Function

Let’s write a very simple function to show a “Toast” when our App is launched. Note that in Kotlin a function is explicitly defined with the “fun” keyword. We then call that function in the onCreate method:

Step 6 – Launch and See!

Hit the “Play” button or press Command-R (Mac) or Ctrl-R (PC) or something else (Linux) to run your app in your favourite emulator. You may need to download the emulator if Android Studio prompts you to do so. You should see:

Kotlin for Android – Create Your First App

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Share This

Get your FREEapp monetisation flowchart!

Use our epic flowchart to help you find the money in your idea! If you're thinking of making an app then this is vital information!


You have subscribed! Please check your email to confirm this subscription and to receive your item!