Google Android Studio Kotlin

Source: Internet
Author: User

Google Android Studio Kotlin Development environment Configuration

Google's recent developer conference announced that Kotlin become the first language of Android development, that is, the official Android language development, it can be seen that Google Kotlin attention, this article describes the Android Kotlin Development environment Configuration and sample programs under Studio.

Because the landlord is a C + + programmer, not Java origin, also do not understand the mobile Android development, spare time want to learn Android mobile development, but the landlord did not want to learn Java, how is good (O (∩_∩) o haha ~), just Kotlin came.

First, Kotlin Introduction:

Official website: http://kotlinlang.org/

Official Learning Document: http://kotlinlang.org/docs/reference/

Kotlin is developed by JetBrains and is a JVM-based programming language;

In Android Stduio can convert Java code to Kotlin code, (more than Java features more powerful, new language, of course, will be more excellent, Google is completely to replace Java AH)

Kotlin can be compiled into Java bytecode, compiled into JavaScript, can run well on devices without a JVM;

JetBrains has already open source its Kotlin programming language under the Apache license;

Recently Kotlin has officially become the official Android language development, attracting a large number of developers to come to learn;

Second, Android Studio Kotlin development environment Configuration

Let me introduce the Kotlin development environment configuration under Android Studio, first of all, the landlord is installed Google's Android Studio integrated development environment, not the eclipse IDE

The landlord's Android studio version is as follows:

(i), create Kotlin Android project

1), first open the Android Studio integrated development environment, click File New Project, the project name is Kotlindemo

2), Click Next, select Android 4.4 KitKat, corresponding Kotlin, you can convert Java code to Kotlin code

3), Click Next to continue, select Empty Activity, click Next to continue

4), Select Finish to complete the creation

(b), configuration Kotlin

Open the project, see the current project source code files are in. Java End Java source code, Mainactivity.java, Exampleinstrumentedtest.java These, we want to turn it kotlin need to build environment.

1), Configuration Kotlin Development Plug-in, click the File menu, select Settings, select Plugins, will show the extension of the plugin.

2), then select Browse repositories ..., search column search Kotlin can, click Install on line, size 50 m, fast.

3), after the completion of the installation of Kotlin, restart Android Studio, this time, we can find in the Code menu directory, convert Java file to Kotlin file, is not very powerful.

4), Click Convert Java file to Kotlin files, will convert the current project's Java document to the corresponding Kotlin file. I believe that Google will gradually strengthen the kotlin support, because Kotlin is the official AH.

Note that when converting the entire project root directory, this will be the entire project of the Java files are converted, if you want to convert only one Java file, you can just click on that file name, and then click Convert Java file to Kotlin file complete the conversion.

Ending with a. KT Kotlin code is as follows:

5), after the conversion is complete, the configuration is not finished, you need to further configure the Kotlin compilation environment, click the Configure button on the top right

6), Choose to configure all the modules, click OK, you can view the build file under the relevant configuration items added.

To this kotlin configuration is complete.

(iii), run Kotlindemo demo, click Debug Debug Run.

The demo works as follows:

This configuration has ended, Kotlin learning to continue, there is a desire to learn the language, we have a lot of communication

qq:1160113606

Email: [Email protected]

Google Android Studio Kotlin

Related Article

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.