Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletter Hub
Free Learning
Arrow right icon
timer SALE ENDS IN
0 Days
:
00 Hours
:
00 Minutes
:
00 Seconds
How to Build Android Applications with Kotlin
How to Build Android Applications with Kotlin

How to Build Android Applications with Kotlin: A hands-on guide to developing, testing, and publishing production-grade Android 16 apps , Third Edition

Arrow left icon
Profile Icon Alex Forrester Profile Icon Eran Boudjnah Profile Icon Alexandru Dumbravan Profile Icon Jomar Tigcal
Arrow right icon
$19.99 per month
Paperback Sep 2025 654 pages 3rd Edition
eBook
€26.98 €29.99
Paperback
€37.99
Subscription
Free Trial
Renews at $19.99p/m
Arrow left icon
Profile Icon Alex Forrester Profile Icon Eran Boudjnah Profile Icon Alexandru Dumbravan Profile Icon Jomar Tigcal
Arrow right icon
$19.99 per month
Paperback Sep 2025 654 pages 3rd Edition
eBook
€26.98 €29.99
Paperback
€37.99
Subscription
Free Trial
Renews at $19.99p/m
eBook
€26.98 €29.99
Paperback
€37.99
Subscription
Free Trial
Renews at $19.99p/m

What do you get with a Packt Subscription?

Free for first 7 days. $19.99 p/m after that. Cancel any time!
Product feature icon Unlimited ad-free access to the largest independent learning library in tech. Access this title and thousands more!
Product feature icon 50+ new titles added per month, including many first-to-market concepts and exclusive early access to books as they are being written.
Product feature icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Product feature icon Thousands of reference materials covering every tech concept you need to stay up to date.
Subscribe now
View plans & pricing
Table of content icon View table of contents Preview book icon Preview Book

How to Build Android Applications with Kotlin

Creating Your First App

This chapter is an introduction to Android, where you will set up the Android Studio environment and focus on the fundamentals of Android development.

You will cover creating an Android project with Android Studio. Then, you will set up a virtual device and run your app on it. You will explore the Android manifest file, which details all the Android app components, features, and permissions model. You will learn how to use the Gradle build system and analyze the Android application structure. You will start developing user interfaces (UIs) with the Android UI toolkit, Jetpack Compose.

By the end of this chapter, you will have gained the knowledge required to create an Android app from scratch and install it on a virtual Android device. You will be able to analyze and understand the importance of the AndroidManifest.xml file. You will know how an app project is structured in Android Studio and use the Gradle build tool to configure and build your app...

Join our book community on Discord

A qr code with an orange square and a white symbol

https://packt.link/EarlyAccessCommunity

This chapter is an introduction to Android, where you will set up the Android Studio environment and focus on the fundamentals of Android development.You will cover creating an Android project with Android Studio. Then, you will set up a virtual device and run your app on it. You will explore the Android manifest file, which details all the Android app components, features and permissions model. You will learn how to use the Gradle build system and analyze the Android application structure. You will start developing user interfaces (UIs) with the Android UI toolkit, Jetpack Compose.By the end of this chapter, you will have gained the knowledge required to create an Android app from scratch and install it on a virtual Android device. You will be able to analyze and understand the importance of the AndroidManifest.xml file. You will learn how an app project is structured in Android Studio and use...

Technical requirements

The complete code for all the exercises and the activity in this chapter is available on GitHub at https://github.com/PacktPublishing/How-to-Build-Android-Apps-with-Kotlin-Third-Edition/tree/main/Chapter01.

Creating an Android project with Android Studio

In order to be productive building Android apps, it is essential to become confident with using Android Studio. This is the official integrated development environment (IDE) for Android development, built on JetBrains’ IntelliJ IDEA IDE and developed by the Android Studio team at Google. You will use it throughout this course to create apps and progressively add more advanced features.Since Google I/O 2017 (the annual Google developer conference), Kotlin has been Google’s preferred programming language for Android app development. You will be using Kotlin throughout this book to build Android apps.Kotlin was created to address some of the shortcomings of Java in terms of verbosity, handling null types, and adding more functional programming techniques, amongst many other issues.Getting to grips and familiarizing yourself with Android Studio will enable you to feel confident building Android apps. So, let’...

Setting up a virtual device and running your app

As a part of installing Android Studio, you downloaded and installed the latest Android software development kit (SDK) components. This includes a base emulator, which you will configure to create a virtual device to run Android apps on. An emulator mimics the hardware and software features and configuration of a real device. The benefit is that you can make changes and quickly see them on your desktop while developing your app. Although virtual devices do not have all the features of a real device, the feedback cycle is often quicker than going through the steps of connecting a real device.The screen you will have seen (or something similar) when installing Android Studio is as follows:

Figure 1.4 – SDK components

Let’s take a look at the SDK components that are installed and how the virtual device fits in:

  • Android Emulator: This is the base emulator, which...

The Android manifest file

The app you have just created, although simple, encompasses the core building blocks that you will use in all the projects you create. The app is driven from the AndroidManifest.xml file, a manifest file that details the contents of your app. To open it, locate the tool window by selecting View | Tool Windows | Project. Once displayed, the drop-down options on the top of the Project window allow you to change the way you view your project, with the most commonly used displays being Android and Project:

Figure 1.14 – The Tool Windows drop-down menu

The AndroidManifest.xml file is located at app | manifests in the Android display of the Project window:

<?xml version="1.0" encoding="utf-8"?>
<manifest
    xmlns:android="
        http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools">
    <application...

Using Gradle to build, configure, and manage app dependencies

In the course of creating this project, you have principally used the Android platform SDK. The necessary Android libraries were downloaded when you installed Android Studio. However, these are not the only libraries that are used to create your app. To configure and build your Android project or app, a build tool called Gradle is used.Gradle is a multi-purpose build tool that Android Studio uses to build your app. You can either use Kotlin or Groovy, a dynamically typed Java virtual machine (JVM) language, to configure the build process and allow easy dependency management so you can add libraries to your project and specify the versions.As the default language when creating a new project in Android Studio is Kotlin, you will be using this. The files that this build and configuration information is stored in are named build.gradle.kts, which are Kotlin script files. You benefit from the same autocompletion and...

Android application structure

Now that we have covered how the Gradle build tool works, we’ll explore the rest of the project. The simplest way to do this is to examine the folder structure of the app. Open up the Project tool window.When you select it, you will see a view like the screenshot in Figure 1.17. If you can’t see any window bars on the left-hand side of the screen, then go to the top toolbar and select View | Appearance | Tool Window Bars and make sure it is ticked.Open the corresponding folders in the Android display. This view neatly groups the app folder structure, so let’s look at it:

Figure 1.17 – Overview of the files and folder structure in the app

The Kotlin file (MainActivity), which you’ve specified as running when the app starts, is as follows:

import…
class MainActivity : ComponentActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
 ...

Summary

This chapter has covered a lot about the foundations of Android development. You started with how to create Android projects using Android Studio and then created and ran apps on a virtual device.The chapter then progressed by exploring the AndroidManifest file, which details the contents of your app and the permission model, followed by an introduction to Gradle and the process of adding dependencies and building your app.This was then followed by going into the details of an Android application and the files and folder structure. Jetpack Compose was introduced, and exercises iterated to illustrate how to construct UIs with an introduction to Google’s Material Design.The next chapter will build on this knowledge by learning about the activity life cycle, activity tasks, and launch modes, persisting and sharing data between screens, and how to create robust user journeys through your app

Left arrow icon Right arrow icon
Download code icon Download Code

Key benefits

  • Build real-world Android apps with Kotlin and the Jetpack Compose UI framework
  • Leverage the latest libraries to accelerate your Android development
  • Overcome development challenges with tips and tricks from experienced Android professionals
  • Get With Your Book: PDF Copy, AI Assistant, and Next-Gen Reader Free

Description

Written by four veteran developers with 60+ years of collective experience, this updated third edition will jumpstart your Android development journey, focusing on Kotlin libraries and Jetpack Compose, Google’s powerful declarative UI framework. You’ll learn the fundamentals of app development, enabling you to use Android Studio, as well as get to grips with Jetpack Compose to create your first screens, build apps to run them on virtual devices through guided exercises, and implement Jetpack Compose’s layout groups to make the most of lists, images, and maps. The book has been updated with Kotlin’s powerful networking and coroutines libraries to help you fetch data in the background from a web service and manage displaying the data using Kotlin flows. You’ll learn about testing, creating clean architecture, and persisting data, as well as exploring the dependency injection pattern and learning how to publish your apps on the Google Play Store. You'll also work on realistic projects split up into bite-size exercises and activities, along with building apps to create quizzes, read news articles, check weather reports, store recipes, retrieve movie information, and remind you where you parked your car. By the end of this book, you'll have gained the skills and confidence to build your own creative Android apps using Kotlin.

Who is this book for?

This book is for beginners as well as intermediate-level developers with no prior experience in Android app development. Basic knowledge of the Kotlin programming language or experience in a similar programming language, along with a willingness to brush up on Kotlin is required.

What you will learn

  • Create maintainable and scalable apps using Kotlin
  • Grasp Android asynchronous programming with coroutines and the Flow API
  • Simplify app development with Google architecture components
  • Apply MVVM and Repository architecture patterns to standardize retrieving and displaying data from outside sources
  • Increase app stability and robustness with unit and integration tests
  • Use standard libraries for dependency injection, networking, data parsing, and persistence
  • Publish your app on the Google Play Store

Product Details

Country selected
Publication date, Length, Edition, Language, ISBN-13
Publication date : Sep 05, 2025
Length: 654 pages
Edition : 3rd
Language : English
ISBN-13 : 9781835882764
Languages :
Tools :

What do you get with a Packt Subscription?

Free for first 7 days. $19.99 p/m after that. Cancel any time!
Product feature icon Unlimited ad-free access to the largest independent learning library in tech. Access this title and thousands more!
Product feature icon 50+ new titles added per month, including many first-to-market concepts and exclusive early access to books as they are being written.
Product feature icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Product feature icon Thousands of reference materials covering every tech concept you need to stay up to date.
Subscribe now
View plans & pricing

Product Details

Publication date : Sep 05, 2025
Length: 654 pages
Edition : 3rd
Language : English
ISBN-13 : 9781835882764
Languages :
Tools :

Packt Subscriptions

See our plans and pricing
Modal Close icon
$19.99 billed monthly
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Simple pricing, no contract
$199.99 billed annually
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just $5 each
Feature tick icon Exclusive print discounts
$279.99 billed in 18 months
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just $5 each
Feature tick icon Exclusive print discounts

Table of Contents

23 Chapters
Android Foundation Chevron down icon Chevron up icon
Creating Your First App Chevron down icon Chevron up icon
Building User Screen Flows Chevron down icon Chevron up icon
Developing the UI with Jetpack Compose Chevron down icon Chevron up icon
Building App Navigation Chevron down icon Chevron up icon
App Components Chevron down icon Chevron up icon
Essential Libraries – Ktor, Kotlin Serialization, and Coil Chevron down icon Chevron up icon
Building Lists with Jetpack Compose Chevron down icon Chevron up icon
Android Permissions and Google Maps Chevron down icon Chevron up icon
Services, WorkManager, and Notifications Chevron down icon Chevron up icon
Code Structure Chevron down icon Chevron up icon
Testing with JUnit, Mockito, MockK, and Compose Chevron down icon Chevron up icon
Coroutines and Flow Chevron down icon Chevron up icon
Android Architecture Components Chevron down icon Chevron up icon
Persisting Data Chevron down icon Chevron up icon
Dependency Injection with Dagger, Hilt, and Koin Chevron down icon Chevron up icon
Polishing and Publishing an App Chevron down icon Chevron up icon
Architecture Patterns Chevron down icon Chevron up icon
Advanced Jetpack Compose Chevron down icon Chevron up icon
Launching Your App on Google Play Chevron down icon Chevron up icon
Unlock Your Book’s Exclusive Benefits Chevron down icon Chevron up icon
Other Books You May Enjoy Chevron down icon Chevron up icon
Index Chevron down icon Chevron up icon
Get free access to Packt library with over 7500+ books and video courses for 7 days!
Start Free Trial

FAQs

What is included in a Packt subscription? Chevron down icon Chevron up icon

A subscription provides you with full access to view all Packt and licnesed content online, this includes exclusive access to Early Access titles. Depending on the tier chosen you can also earn credits and discounts to use for owning content

How can I cancel my subscription? Chevron down icon Chevron up icon

To cancel your subscription with us simply go to the account page - found in the top right of the page or at https://subscription.packtpub.com/my-account/subscription - From here you will see the ‘cancel subscription’ button in the grey box with your subscription information in.

What are credits? Chevron down icon Chevron up icon

Credits can be earned from reading 40 section of any title within the payment cycle - a month starting from the day of subscription payment. You also earn a Credit every month if you subscribe to our annual or 18 month plans. Credits can be used to buy books DRM free, the same way that you would pay for a book. Your credits can be found in the subscription homepage - subscription.packtpub.com - clicking on ‘the my’ library dropdown and selecting ‘credits’.

What happens if an Early Access Course is cancelled? Chevron down icon Chevron up icon

Projects are rarely cancelled, but sometimes it's unavoidable. If an Early Access course is cancelled or excessively delayed, you can exchange your purchase for another course. For further details, please contact us here.

Where can I send feedback about an Early Access title? Chevron down icon Chevron up icon

If you have any feedback about the product you're reading, or Early Access in general, then please fill out a contact form here and we'll make sure the feedback gets to the right team. 

Can I download the code files for Early Access titles? Chevron down icon Chevron up icon

We try to ensure that all books in Early Access have code available to use, download, and fork on GitHub. This helps us be more agile in the development of the book, and helps keep the often changing code base of new versions and new technologies as up to date as possible. Unfortunately, however, there will be rare cases when it is not possible for us to have downloadable code samples available until publication.

When we publish the book, the code files will also be available to download from the Packt website.

How accurate is the publication date? Chevron down icon Chevron up icon

The publication date is as accurate as we can be at any point in the project. Unfortunately, delays can happen. Often those delays are out of our control, such as changes to the technology code base or delays in the tech release. We do our best to give you an accurate estimate of the publication date at any given time, and as more chapters are delivered, the more accurate the delivery date will become.

How will I know when new chapters are ready? Chevron down icon Chevron up icon

We'll let you know every time there has been an update to a course that you've bought in Early Access. You'll get an email to let you know there has been a new chapter, or a change to a previous chapter. The new chapters are automatically added to your account, so you can also check back there any time you're ready and download or read them online.

I am a Packt subscriber, do I get Early Access? Chevron down icon Chevron up icon

Yes, all Early Access content is fully available through your subscription. You will need to have a paid for or active trial subscription in order to access all titles.

How is Early Access delivered? Chevron down icon Chevron up icon

Early Access is currently only available as a PDF or through our online reader. As we make changes or add new chapters, the files in your Packt account will be updated so you can download them again or view them online immediately.

How do I buy Early Access content? Chevron down icon Chevron up icon

Early Access is a way of us getting our content to you quicker, but the method of buying the Early Access course is still the same. Just find the course you want to buy, go through the check-out steps, and you’ll get a confirmation email from us with information and a link to the relevant Early Access courses.

What is Early Access? Chevron down icon Chevron up icon

Keeping up to date with the latest technology is difficult; new versions, new frameworks, new techniques. This feature gives you a head-start to our content, as it's being created. With Early Access you'll receive each chapter as it's written, and get regular updates throughout the product's development, as well as the final course as soon as it's ready.We created Early Access as a means of giving you the information you need, as soon as it's available. As we go through the process of developing a course, 99% of it can be ready but we can't publish until that last 1% falls in to place. Early Access helps to unlock the potential of our content early, to help you start your learning when you need it most. You not only get access to every chapter as it's delivered, edited, and updated, but you'll also get the finalized, DRM-free product to download in any format you want when it's published. As a member of Packt, you'll also be eligible for our exclusive offers, including a free course every day, and discounts on new and popular titles.

Modal Close icon
Modal Close icon