Use Kotlin to develop Android and kotlin to develop android

Source: Internet
Author: User

Use Kotlin to develop Android and kotlin to develop android

Check out all my open-source projects [open-source lab]
Welcome to my QQ group: [201055521]. Please click to download the source code of this blog client]

Summary

I first declared that I didn't use Kotlin for a long time. I wrote these articles almost simultaneously. I didn't try any other alternative languages, such as Go and Scala, so if you really want to change the development language, I suggest you search for other people's comments on these languages.
This article is original, reprint please note address: http://blog.kymjs.com/

Body

Recently, I learned a new programming language called Kotlin. Kotlin is an open-source project initiated by Jetbrains for internal development. You may not have heard of Jetbrains, but you must have heard of IntelliJ IDEA, that's right. The mom of Android Studio is the product of this company. Kotlin is based on JVM. The reason for introducing Kotlin is that it has high interconnectivity with Java and IDE support, and of course it is also the most important, it is superior to java as the language itself.

Why is Kotlin used?

If a programming language is not enough to change your programming thinking, it fails. We are familiar with static languages such as C, Obj-C, and JAVA. It is time to learn dynamic languages such as Swift, Go, and Kotlin.
The second reason is that Kotlin can indeed omit a lot of coding and its unique language features.
The third reason is that compared with Sala and Go, Kotlin is perfectly compatible with existing Java code, that is, development frameworks such as Volley, KJFrameForAndroid, and OKHttp that we usually use, it still works normally in the Kotlin language.

IDE Selection

My style is still my main practice. This article will first explain how to use Kotlin to develop a Hello World Android app.
The first is IDE. Kotlin also supports Eclipse development. Although I am an Eclipse brain fan, I will not talk about it here because you know that Eclipse is old. Here we will explain how to use Kotlin to develop Android applications in AndroidStudio.

Development Environment Configuration

1. Start AndroidStudio, command +, Open Preference (search for the corresponding shortcut in windows), search for plugin, open the plug-in interface, click BrowseRepository, search for Kotlin, double-click to install Kotlin and Kotlin Extension For Android. The first is the Kotlin language support package, and the second is the feature enhancement package we will use later.


If you are unable to download because of the wall, there is an offline package for the first plug-in below my new blog homepage (http://kymjs.com.
2. With the language support package, we can create an Android project. After creating a common Android project, click Code> Convert Java File to Kotlin File. The default shortcut key is a bit lengthy. Here I directly set the shortcut key to command + 5, which will be much easier to convert later.

After the conversion, we will find some changes in our original java class. By observing the file extension, we can see that the file has changed from. java to. kt.
3. Choose Tool> Kotlin> Configure Kotlin in Project.
(Here, I will mention that many tutorials on the Internet are translated from these four articles, saying that you need to manually configure build. gradle, but these four articles have been around for a long time. Now Kotlin can be configured with AS with one click) we chose the latest version 0.12.613 (You may see many terms such as Kotlin M12 and M11 on the Internet, which refer to version 0.12, which is similar to Android 17, Android 22, and Java8)

4. Click "OK". The following is a long wait. AndroidStudio is downloading the relevant configuration (we recommend that you flip the wall). After the download is complete, we can run this Android application.

The above is the HelloWorld of Kotlin For Android. Next we will explain the basic syntax of Kotlin and the odd tricks in development.

Copyright Disclaimer: This article is an original article by the blogger and cannot be reproduced without the permission of the blogger.

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.