Converting code from Java to Kotlin in Android Studio

Viewed 16104

Can anyone explain how to replace existing Java code with Kotlin within Android Studio?

2 Answers

If you've got Kotlin already configured in your Android Studio project, you can follow the steps outlined here to automatically convert with the instructions here.

From the site:

  • On the main menu, point to Code menu.
  • Choose Convert Java File to Kotlin File.

If you are using android studio 3.5+, Just select your java file from your package, right click on it and select Convert Java file to Kotlin file from the bottom of popup menu

Related