Create new Java Android Studio Project

Create Android Studio Project by checking the checkBox Include Kotlin support.

To create new  Android Studio Project, you can find more details here.

Step 2

Convert Java file to Kotlin

A new android studio project, is still coded in java and contains a main java file named In this tutorial, we'll see how to convert this file to kotlin to get a MainActivity.kt kotlin file. Here is the original code of

public class MainActivity extends AppCompatActivity {

protected void onCreate(Bundle savedInstanceState) {

To convert this file to kotlin, just click on the code menu and choose convert java file to kotlin

after converting your java file to kotlin, you get a new Kotlin MainActivity.kt file whose code is:

class MainActivity : AppCompatActivity() {

override fun onCreate(savedInstanceState: Bundle?) {

Note : You can also use the online tool to convert java file to Kotlin

To convert your java code to kotlin with this tool, click on the "Convert from Java" button

Now copy and past your code in the left editor :

and then click on the "Convert to Kotlin" button

Younes Derfoufi 

Leave a Reply