How to set up kotlin into android project

In this post I want to show how to start an android project with some kotlin classes:

Start android studio and install the kotlin plugin: go to “search everywhere” and write plugin. In Plugins select kotlin and install it.

Schermata 2016-03-30 alle 18.11.37

Schermata 2016-03-30 alle 18.13.02.png

After this, create a new Android project and then, into search everywhere, type Configure kotlin and select Configure kotlin in project. This operation modify your build.grandle and add some rows:

Schermata 2016-03-30 alle 18.13.43

Schermata 2016-03-30 alle 18.19.18.png

After this operation it’s possible to convert java code into kotlin code, so it’s possible to convert an activity written in java, into activity written in kotlin: Select the activity to convert and then select  “Convert java file to kotlin file” from Code menu

Schermata 2016-03-30 alle 18.20.43.png

 

Now we can start to write our kotlin code in this android project.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s