Search icon CANCEL
Subscription
0
Cart icon
Cart
Close icon
You have no products in your basket yet
Save more on your purchases!
Savings automatically calculated. No voucher code required
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Android Development with Kotlin

You're reading from  Android Development with Kotlin

Product type Book
Published in Aug 2017
Publisher Packt
ISBN-13 9781787123687
Pages 440 pages
Edition 1st Edition
Languages
Authors (2):
Igor Wojda Igor Wojda
Profile icon Igor Wojda
Marcin Moskala Marcin Moskala
Profile icon Marcin Moskala
View More author details
Toc

Table of Contents (16) Chapters close

Title Page
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Customer Feedback
Preface
1. Beginning Your Kotlin Adventure 2. Laying a Foundation 3. Playing with Functions 4. Classes and Objects 5. Functions as First-Class Citizens 6. Generics Are Your Friends 7. Extension Functions and Properties 8. Delegates 9. Making Your Marvel Gallery Application

Kotlin under the hood


We will focus mainly on Android, but keep in mind that Kotlin can be compiled to multiple platforms. Kotlin code can be compiled to Java bytecode and then to Dalvik bytecode. Here is the simplified version of the Kotlin build process for the Android platform:

  • A file with a .java extension contains Java code
  • A file with a .kt extension contains Kotlin code
  • A file with a .class extension contains Java bytecode
  • A file with a .dex extension contains Dalvik bytecode
  • A file with a .apk extension contains the AndroidManifest file, resources, and .dex file

For pure Kotlin projects, only the Kotlin compiler will be used, but Kotlin also supports cross-language projects, where we can use Kotlin together with Java in the same Android project. In such cases, both compilers are used to compile the Android application and the result will be merged at the class level.

The Kotlin standard library

The Kotlin standard library (stdlib) is a very small library that is distributed together with Kotlin. It is required to run applications written in Kotlin and it is added automatically to our application during the build process.

Note

In Kotlin 1.1, kotlin-runtime was required to run applications written in Kotlin. In fact, in Kotlin 1.1 there were two artifacts (kotlin-runtime and kotlin-stdlib) that shared a lot of Kotlin packages. To reduce the amount of confusion, both the artifacts will be merged into a single artifact (kotlin-stdlib) in the upcoming 1.2 version of Kotlin. Starting from Kotlin 1.2, kotlin-stdlib is required to run applications written in Kotlin.

The Kotlin standard library provides essential elements required for everyday work with Kotlin. These include:

  • Data types such as arrays, collections, lists, ranges, and so on
  • Extensions
  • Higher-order functions
  • Various utilities for working with strings and char sequences
  • Extensions for JDK classes, making it convenient to work with files, IO, and threading
You have been reading a chapter from
Android Development with Kotlin
Published in: Aug 2017 Publisher: Packt ISBN-13: 9781787123687
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at €14.99/month. Cancel anytime}