Develop your first Android app with Kotlin

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.