

Project directly (not using the Android templates), Android Studio displays a If this is the first time you have added a new Kotlin class or file to your If youĬhoose Class, Android Studio creates a new Kotlin source file with the given The choice you makeĭetermines the basic scaffolding created for you in the new Kotlin file. The New Kotlin File/Class window lets youĭefine the file name and provides several choices for the file type: File,Ĭlass, Interface, Enum Class, or Object. If you don't see this option, open the Project window and A New Android Activity dialog where you canĪlternatively, you can click File > New > Kotlin File/Class to create aīasic Kotlin file. In the wizard that appears, choose Kotlin for the Source Language.įigure 2 shows the New Android Activity dialog for when you want toĬreate a new activity. Choose from the available templates, such as fragment


Of templates in this menu, first open the Project window, and select yourĪpp module. To add Kotlin to your project, do the following:Ĭlick File > New, and choose one of the various Android templates, suchĪs a new blank Fragment, as shown in figure 1. If you're starting a new project and want to use Kotlin, see Including autocomplete, lint checking, refactoring, debugging, and more. You can then use all of Android Studio's existing tools with your Kotlin code, Kotlin files to your existing project and convert Java language code to Kotlin. Just open the class you want to convert and chos the option Code -> Convert Java File to Kotlin File.Īnd that’s all.Android Studio provides full support for Kotlin, enabling you to add The Kotlin plugin includes a conversor from Java to Kotlin code (not the other way round, but you won’t want it anyway 😝). It will be easier to convert the code later. Nothing different from a regular project:Ĭhoose “Blank Screen” among the “New Activity” options. Now that you’ve installed your plugin (you can even do it later if you want), create an Android Project. In order to do this, go to Plugins section in “Preferences”, and use the search bar to find it:

IntelliJ comes with it already installed by default, but it’s not the same for Android Studio. Canary or Beta should be OK, but new versions sometimes break the Kotlin plugin for some days. Creating an Android project for Kotlin from scratchįirst thing you need is to download the latest stable version of Android Studio.
