Brief insight into kotlin with android studio usage
Posted By : Keshav Gupta | 23-Jun-2017
Install Kotlin in android studio:
Android Studio 3.0 version will be released with Kotlin internally i.e user do not need to install extra plugin for support. But before 3.0 user need to install kotlin plugin from ''file/settings/plugins/browserepositories/".
Now type "Kotlin" and install plugin and after installation studio will ask to restart IDE.So after restarting android studio will open including kotlin support.
Android Development using kotlin:
Step 1: create a new Android studio project with a blank activity
Step 2: Open main Activity and delete everything in the file except oncreate
Step 3: Rename java dir to kotlin
Step 4: convert java activity file to kotlin
Select 'convert java file to kotlin file" from code menu item in menu window.
Step 5: change oncreate's argument from bundle to bundle? (i.e. nullable) in the generated file
Step 6: convert project to kotlin (this modifies build.gradle)
Go to tools/kotlin/configure kotlin in project
Step 7: select v0.8.11
Choose kotlin plugin version v0.8.11 in window appear
Step 8: Compile project. Now are you good to go
Reference and learning syntax:go to
https://kotlinlang.org/docs/reference/android-overview.html
THANKS
Cookies are important to the proper functioning of a site. To improve your experience, we use cookies to remember log-in details and provide secure log-in, collect statistics to optimize site functionality, and deliver content tailored to your interests. Click Agree and Proceed to accept cookies and go directly to the site or click on View Cookie Settings to see detailed descriptions of the types of cookies and choose whether to accept certain cookies while on the site.
About Author
Keshav Gupta
Keshav Gupta is Android Developer in Oodles, he always look forward for new tasks and new things to learn more.