Search icon
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Mastering Kotlin for Android 14

You're reading from  Mastering Kotlin for Android 14

Product type Book
Published in Apr 2024
Publisher Packt
ISBN-13 9781837631711
Pages 370 pages
Edition 1st Edition
Languages
Author (1):
Harun Wangereka Harun Wangereka
Profile icon Harun Wangereka

Table of Contents (22) Chapters

Preface 1. Part 1: Building Your App
2. Chapter 1: Get Started with Kotlin Android Development 3. Chapter 2: Creating Your First Android App 4. Chapter 3: Jetpack Compose Layout Basics 5. Chapter 4: Design with Material Design 3 6. Part 2: Using Advanced Features
7. Chapter 5: Architect Your App 8. Chapter 6: Network Calls with Kotlin Coroutines 9. Chapter 7: Navigating within Your App 10. Chapter 8: Persisting Data Locally and Doing Background Work 11. Chapter 9: Runtime Permissions 12. Part 3: Code Analysis and Tests
13. Chapter 10: Debugging Your App 14. Chapter 11: Enhancing Code Quality 15. Chapter 12: Testing Your App 16. Part 4: Publishing Your App
17. Chapter 13: Publishing Your App 18. Chapter 14: Continuous Integration and Continuous Deployment 19. Chapter 15: Improving Your App 20. Index 21. Other Books You May Enjoy

Preface

Kotlin is a programming language created by JetBrains that runs on the Java Virtual Machine (JVM). It was designed to address issues such as verbosity, null pointer exceptions, concurrency challenges, and the lack of functional support found in Java. Kotlin offers a more modern and concise programming approach while still being compatible with existing Java code and libraries. Google recognized Kotlin as a primary language for building Android apps, leading to significant efforts to support developers. This book adopts an industry-focused approach, preparing you for the role of an Android developer in any company. It follows current best practices recommended by Google’s Android team, providing insights based on practical experience.

With practical examples, the book guides you through developing Android apps using Kotlin, imparting hands-on knowledge that is essential for becoming a proficient Android developer. Topics include building apps with Jetpack Compose, incorporating Material Design 3 for a personalized touch, and structuring apps in the MVVM architecture. The guide further demonstrates how to enhance your app’s architecture with features such as dependency injection, use Jetpack Libraries such as Room for local data persistence, and implement debugging techniques. It covers testing, identifying code issues using tools such as Ktlint and Detekt, and guides you through the publication process on Google Play Store. Automation of consecutive releases through GitHub Actions and the distribution of test builds using Firebase App Distribution are also explored. Additionally, the book addresses app improvement strategies, including crash reporting tools, tips for boosting user engagement, and insights on securing your app.

Who this book is for

This book is for aspiring Android developers or Android developers working with Java, as they’ll learn how to build Android apps with Kotlin from scratch, learn about architecture and other pertinent topics in Android, and finally, know how to publish their apps to Google Play Store. The book is written with current best practices in mind and also guides you to prepare for a role as an Android developer.

What this book covers

Chapter 1, Get Started with Kotlin Android Development, introduces Kotlin as a programming language. It covers features that are useful for Android development and its importance for Android developers. Additionally, it covers how to migrate from Java to Kotlin and some useful tips for developers coming from Java backgrounds.

Chapter 2, Creating Your First Android App, covers how to create Android apps. It familiarizes you with Android Studio, the Integrated Development Environment (IDE) that you will use to develop Android apps. It also covers some tips, shortcuts, and useful Android Studio features and explores the process of creating a project in Android Studio.

Chapter 3, Jetpack Compose Layout Basics, looks at Jetpack Compose, a declarative way of creating user interfaces for apps. It covers the basics of Jetpack Compose and its layouts.

Chapter 4, Design With Material Design 3, introduces Material 3 and the features that it offers. It also covers how to use Material 3 in Android apps and some of its components.

Chapter 5, Architect Your App, explores the different architectures available for Android projects. It dives deep into the MVVM architecture and its different layers and how to use some of the Jetpack libraries within it. Additionally, it shows you how to use advanced architecture features, such as dependency injection, the Kotlin Gradle DSL, and a version catalog to define dependencies.

Chapter 6, Network Calls with Kotlin Coroutines, discusses how to perform network calls with a networking library, Retrofit. It shows how to consume Application Programming Interfaces (APIs) using this library. Moreover, it covers how to take advantage of Kotlin coroutines to perform asynchronous network requests.

Chapter 7, Navigating within Your App, explains how to use the Jetpack Compose Navigation library to navigate to different Jetpack Compose screens. It covers the tips and best practices for using this library. Moreover, it covers how to pass arguments as we navigate to screens. Lastly, it covers how to handle navigation on large screens and foldables.

Chapter 8, Persisting Data Locally and Doing Background Work, covers how to save data to a local database, Room, which is part of the Jetpack libraries. It shows how to save items and read from the Room database. Additionally, it covers how to do long-running operations using WorkManager and some of the best practices.

Chapter 9, Runtime Permissions, delves into runtime permissions and how to request runtime permissions.

Chapter 10, Debugging Your App, discusses debugging tips and tricks, how to detect leaks using LeakCanary, how to inspect network requests/responses fired by apps using Chucker, and how to inspect the Room database, network requests, and background tasks using App Inspection.

Chapter 11, Enhancing Code Quality, explores the Kotlin style and the best practices for writing Kotlin code. It also demonstrates how to use plugins such as Ktlint and Detekt to format, lint, and detect code smells early.

Chapter 12, Testing Your App, examines how to add tests for the different layers in the MVVM architecture. It covers the importance of adding tests and how to add unit tests, integration tests, and instrumentation tests.

Chapter 13, Publishing Your App, delves into how to publish a new app to Google Play Store. It walks through how to create a signed app bundle and topics such as answering questions about the content of our app, creating releases, setting up how users will access the app, either via controlled testing tracks or publicly, and much more. Additionally, it covers some of the Google Play Store policies and how to always stay compliant to avoid apps being removed or accounts being banned.

Chapter 14, Continuous Integration and Continuous Deployment, focuses on how to use GitHub Actions to automate some manual tasks, such as deploying new builds to Google Play Store. It also covers how to run tests on CI/CD pipelines and push builds to Google Play Store using GitHub Actions.

Chapter 15, Improving Your App, covers the techniques of improving apps by adding analytics, Firebase Crashlytics, and using cloud messaging to increase user engagement in apps. It covers how to send notifications to apps from the Firebase console. Additionally, it covers tips and tricks for securing apps to ensure that a user’s data is not compromised.

To get the most out of this book

Software/hardware covered in the book

Operating system requirements

Android Studio Hedgehog or later versions

Windows, macOS, or Linux

Download the example code files

You can download the example code files for this book from GitHub at https://github.com/PacktPublishing/Mastering-Kotlin-for-Android. If there’s an update to the code, it will be updated in the GitHub repository.

We also have other code bundles from our rich catalog of books and videos available at https://github.com/PacktPublishing/. Check them out!

Conventions used

There are a number of text conventions used throughout this book.

Code in text: Indicates code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles. Here is an example: “We created a class named PetsRepositoryImpl that implements the PetsRepository interface.”

A block of code is set as follows:

class PetsViewModel: ViewModel() {
    private val petsRepository: PetsRepository = PetsRepositoryImpl()
    fun getPets() = petsRepository.getPets()
}

When we wish to draw your attention to a particular part of a code block, the relevant lines or items are set in bold:

[default]
exten => s,1,Dial(Zap/1|30)
exten => s,2,Voicemail(u100)
exten => s,102,Voicemail(b100)
exten => i,1,Voicemail(s0)

Any command-line input or output is written as follows:

FATAL EXCEPTION: main
Process: com.packt.chapterten, PID: 7168
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.packt.chapterten/com.packt.chapterten.MainActivity}: java.lang.RuntimeException: This is a crash
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3645)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3782)

Bold: Indicates a new term, an important word, or words that you see on screen. For instance, words in menus or dialog boxes appear in bold. Here is an example: “Tap on the New Project button, which will take us to the Templates screen.”

Tips or important notes

Appear like this.

Get in touch

Feedback from our readers is always welcome.

General feedback: If you have questions about any aspect of this book, email us at customercare@packtpub.com and mention the book title in the subject of your message.

Errata: Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you have found a mistake in this book, we would be grateful if you would report this to us. Please visit www.packtpub.com/support/errata and fill in the form.

Piracy: If you come across any illegal copies of our works in any form on the internet, we would be grateful if you would provide us with the location address or website name. Please contact us at copyright@packt.com with a link to the material.

If you are interested in becoming an author: If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, please visit authors.packtpub.com.

Share Your Thoughts

Once you’ve read Mastering Kotlin for Android 14, we’d love to hear your thoughts! Please click here to go straight to the Amazon review page for this book and share your feedback.

Your review is important to us and the tech community and will help us make sure we’re delivering excellent quality content.

Download a free PDF copy of this book

Thanks for purchasing this book!

Do you like to read on the go but are unable to carry your print books everywhere?

Is your eBook purchase not compatible with the device of your choice?

Don’t worry, now with every Packt book you get a DRM-free PDF version of that book at no cost.

Read anywhere, any place, on any device. Search, copy, and paste code from your favorite technical books directly into your application.

The perks don’t stop there, you can get exclusive access to discounts, newsletters, and great free content in your inbox daily

Follow these simple steps to get the benefits:

  1. Scan the QR code or visit the link below
Download a free PDF copy of this book

https://packt.link/free-ebook/9781837631711

  1. Submit your proof of purchase
  2. That’s it! We’ll send your free PDF and other benefits to your email directly
lock icon The rest of the chapter is locked
Next Chapter arrow right
You have been reading a chapter from
Mastering Kotlin for Android 14
Published in: Apr 2024 Publisher: Packt ISBN-13: 9781837631711
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}