Learning Kotlin for Android - Introduction

in #blog7 years ago

I've been developing Android apps with Java for a few years and I have to say that I'm not a big fan of its syntax where the developer has to write many lines the code for simple stuff, for example, reading from a file. Luckily for us Kotlin has come to the rescue.

Kotlin is the newest and hottest programming language for Android that stands out for being concise and safe. At work, I have started to use it for non-production code and it is AWESOME! That is why I have decided to start this blog series where I'm going to discuss some of the features of Kotlin while building an Android app to display the crypto market capitalization.

Let's start by creating our first Android project with Kotlin.

We're going to need Android Studio, you can download it and still it from here:

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

Kotlin is bundled with the latest version of Android Studio 3.0.1

After installing the IDE we're going to create a new project by clicking on "Start a new Android Studio project". Select a name for the new project and use the empty activity template
Screen Shot 2017-12-04 at 11.45.56 PM.png

After the IDE finish setting up the project we'll have a project with a MainActivity in Java. The next step is to setup Kotlin in our project, the easiest way to do it is by using the action search Command + Shift +A, type Convert Java file to Kotlin file in the search box.
Screen Shot 2017-12-04 at 11.51.39 PM.png

Next, we need to configure Kotlin in our project. We can search for the Configure Kotlin in Project action in AS.

Screen Shot 2017-12-04 at 11.57.11 PM.png

We are ready to run our first app in Kotlin. Click on run app button, select a target device or create an emulator.

Untitled 2.png

There you go! We have our android project ready to start.

In the next post, we're going to review Kotlin features and what it makes it so great for developing android apps.

Cheers!

Coin Marketplace

STEEM 0.22
TRX 0.20
JST 0.034
BTC 92640.23
ETH 3113.67
USDT 1.00
SBD 3.17