Straight to the subject
First step: Install the Kotlin plugin for Androidstudio
Online installation steps: File->settings->plugins->install jetbrains plugin ... The following screen appears, check Kotlin click on the right side of the install (because I have installed so the update upgrade is shown)
Then there is a long wait, after the installation is complete, it will prompt to restart Androidstudio
Due to my online installation did not succeed, chose the offline installation ...
Offline installation Steps
First to download Androidstudio with the Kotlin plugin to share my plugin: Http://pan.baidu.com/s/1mij4ZHY
After download or File->settings->plugins->install plugin from disk ... (Note Last Select Install plugin from disk ...) And on-line installation time choose the Install JetBrains plugin ... Not the same) select the installation path of the plugin you downloaded, click OK
After completion, you will be prompted to restart the reboot (just plug-in installation)
Step Two: Configure Kotlin first create Kotlin Activity, will prompt Kotlin not configured, we direct point configure,
Click android with Gradle
Click OK
The following changes occur at this time after our project:
First the root directory of the Build.gradle file:
First the app's Build.gradle file:
This means your Kotlin configuration is complete and you can develop your first Kotlin project.
Step three: To develop the first Kotlin project, first create a kotlinactivity
Create a new TextView in the kotlinactivity corresponding XML file
Used in kotlinactivity:
Do you want to be too simple?!!! The ID name in direct XML. Text on it!!!!
When the input tv_mytest will be automatically prompted to rewind the Alt+enter, it is the package:
However, I have encountered a problem in the import of this tv_mytest is not prompted to say that there is no such variable .... So Baidu this problem found a solution, is in the app's Build.gradle file add a piece of code
Apply plugin: ' Kotlin-android-extensions '
And where is it?
Sync now solution can run to see your first app written in Kotlin ~ (though it's simple ....) )
Add one thing: Convert the original Java file to a Kotlin file and select your Java file, as in the operation:
Develop your first Android app with Kotlin