Detailed steps for configuring kotlin development environment for Android studio

Detailed steps for configuring kotlin development environment for Android studio

Step 1: install the kotlin plug-in

Open the settings panel, find the plugins option, click Browse repositories, enter "kotlin" to find it, and then install it. After installation, you need to restart Android studio (remember!).

After installation, see the figure below.

The latest version of the plug-in is 1.1.2-release-studio-2.3-3.

Step 2: configure the kotlin development environment

Click the "tools" option in the menu bar, select "kotlin", and then select "configure kotlin project". As shown in the figure below.

In the pop-up window, select the module that needs to use kotlin and the version of kotlin compiler and runtime, as shown in the following figure.

After clicking "OK", the kotlin plug-in will automatically start configuration. After configuration, synchronize the project.

Attachment: recommended configuration

Attachment: write unit tests using kotlin

Various unit tests are inevitable in Android development. Writing unit tests with kotlin can simplify code and improve efficiency. Switch the project to the project view and expand the SRC directory under the module. By default, there will be three folders under this directory. The main folder is usually used to store module code; Android test folder is usually used to store Android related unit tests; The test folder is usually used to store Java (kotlin) - related unit tests.

Unit testing by kotlin

Create a new kotlin class under the test package, for example, named unittest1. Multiple test methods can be written in this class without detailed description.

Unit testing for Android

Create a new kotlin class under the test package, for example, named androidtest1. Multiple test methods can be written in this class without detailed description.

Attachment: some useful information about kotlin official website: http://kotlinlang.org/ Kotlin user manual (English): http://kotlinlang.org/docs/reference/ Kotin open source address: https://github.com/JetBrains/kotlin Official introduction to how to start using kotlin: http://kotlinlang.org/docs/tutorials/getting-started.html Some libraries related to kotlin Framework and application: http://kotlinlang.org/docs/resources.html

Thank you for reading, hope to help you, thank you for your support to this site!

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>