Mastering Kotlin for Android 14

Book description

Accelerate your Android development journey by mastering the latest Kotlin techniques and libraries to build robust apps with the help of this part-color guide

Key Features

  • Apply best practices and industry-essential skills used by Google Developer Experts
  • Find out how to publish, monitor, and improve your app metrics on the Google Play Store
  • Learn how to debug issues, detect leaks, inspect network calls, and inspect your app’s local database
  • Purchase of the print or Kindle book includes a free PDF eBook

Book Description

Written with the best practices, this book will help you master Kotlin and use its powerful language features, libraries, tools, and APIs to elevate your Android apps.

As you progress, you'll use Jetpack Compose and Material Design 3 to build UIs for your app, explore how to architect and improve your app architecture, and use Jetpack Libraries like Room and DataStore to persist your data locally. Using a step-by-step approach, this book will teach you how to debug issues in your app, detect leaks, inspect network calls fired by your app, and inspect your Room database. You'll also add tests to your apps to detect and address code smells.

Toward the end, you’ll learn how to publish apps to the Google Play Store and see how to automate the process of deploying consecutive releases using GitHub actions, as well as learn how to distribute test builds to Firebase App Distribution. Additionally, the book covers tips on how to increase user engagement.

By the end of this Kotlin book, you’ll be able to develop market-ready apps, add tests to their codebase, address issues, and get them in front of the right audience.

What you will learn

  • Build beautiful, responsive, and accessible UIs with Jetpack Compose
  • Explore various app architectures and find out how you can improve them
  • Perform code analysis and add unit and instrumentation tests to your apps
  • Publish, monitor, and improve your apps in the Google Play Store
  • Perform long-running operations with WorkManager and persist data in your app
  • Use CI/CD with GitHub Actions and distribute test builds with Firebase App Distribution
  • Find out how to add linting and static checks on CI/CD pipelines

Who this book is for

If you’re an aspiring Android developer or an Android developer working with Java, then this book is for you. Basic Java programming skills are a must if you want to fully utilize the techniques and best practices showcased in this book.

Table of contents

  1. Mastering Kotlin for Android 14
  2. Contributors
  3. About the author
  4. About the reviewers
  5. Preface
    1. Who this book is for
    2. What this book covers
    3. To get the most out of this book
    4. Download the example code files
    5. Conventions used
    6. Get in touch
    7. Share Your Thoughts
    8. Download a free PDF copy of this book
  6. Part 1: Building Your App
  7. Chapter 1: Get Started with Kotlin Android Development
    1. Technical requirements
    2. Introduction to Kotlin
    3. Kotlin syntax, types, functions and classes
      1. Creating a Kotlin project
      2. Creating functions
      3. Creating classes
    4. Migrating from Java to Kotlin
    5. Kotlin features for Android developers
    6. Summary
  8. Chapter 2: Creating Your First Android App
    1. Technical requirements
    2. Android Studio overview
    3. Creating your Android app
      1. Exploring the new project
    4. Android Studio tips and tricks
      1. Some useful shortcuts
    5. Summary
  9. Chapter 3: Jetpack Compose Layout Basics
    1. Technical requirements
    2. Introduction to Jetpack Compose
      1. Declarative versus imperative UIs
      2. Composable functions
      3. Previews
      4. Modifiers
    3. Jetpack Compose layouts
      1. Column
      2. Row
      3. Box
      4. Lists
    4. Summary
  10. Chapter 4: Design with Material Design 3
    1. Technical requirements
    2. Material Design 3 and its features
      1. Material components
    3. Using Material Design in our apps
      1. Adding Material Design 3 color schemes
    4. Designing UIs for large screens and foldables
      1. Using WindowSizeClass
    5. Making our app accessible
    6. Summary
  11. Part 2: Using Advanced Features
  12. Chapter 5: Architect Your App
    1. Technical Requirements
    2. Introduction to app architecture
    3. Deep Diving into MVVM
      1. How LazyColumn works
      2. Benefits of LazyColumn
      3. Creating a composable
    4. Jetpack libraries
    5. Dependency injection
    6. Migrating to Kotlin Gradle DSL and using version catalogs
      1. Migrating our app to Kotlin Gradle DSL
      2. Using a versions catalog
    7. Summary
  13. Chapter 6: Network Calls with Kotlin Coroutines
    1. Technical requirements
    2. Setting up Retrofit
    3. Introduction to Kotlin coroutines
      1. Coroutine basics
    4. Using Kotlin coroutines for network calls
    5. Summary
  14. Chapter 7: Navigating within Your App
    1. Technical requirements
    2. Jetpack Navigation overview
    3. Navigating to Compose destinations
    4. Passing arguments to destinations
    5. Navigation in foldables and large screens
      1. Creating and using the resizable emulator
    6. Summary
  15. Chapter 8: Persisting Data Locally and Doing Background Work
    1. Technical requirements
    2. Saving and reading data from a local database
    3. Handling updates and migrations in the Room database
    4. Using WorkManager to schedule background tasks
    5. Testing your workers
    6. Summary
  16. Chapter 9: Runtime Permissions
    1. Technical requirements
    2. Understanding runtime permissions
    3. Requesting permissions at runtime
    4. Summary
  17. Part 3: Code Analysis and Tests
  18. Chapter 10: Debugging Your App
    1. Technical requirements
    2. General debugging tips and tricks
      1. Logcat
      2. Stack traces
      3. Breakpoints
    3. Detecting memory leaks with LeakCanary
    4. Inspecting network requests with Chucker
    5. Using App Inspection
    6. Summary
  19. Chapter 11: Enhancing Code Quality
    1. Technical requirements
    2. Mastering Kotlin style and best practices
      1. Coding conventions
      2. Null safety
      3. Data classes
      4. Extensions functions
      5. Type inference
      6. Collections
      7. Sealed classes and interfaces
      8. Formatting
      9. Functional programming
      10. Coroutines
      11. The when statements
      12. Classes and functions
    3. Using Ktlint for static analysis
    4. Detecting code smells with detekt
      1. Setting up detekt
      2. Customizing detekt
    5. Summary
  20. Chapter 12: Testing Your App
    1. Technical requirements
    2. Importance of testing
    3. Testing the network and database layers
      1. Testing the network layer
      2. Testing the database layer
    4. Testing our ViewModels
    5. Adding UI tests to our composables
    6. Summary
  21. Part 4: Publishing Your App
  22. Chapter 13: Publishing Your App
    1. Technical requirements
    2. Preparing our app for release
      1. Add analytics to your app
      2. Add crash reporting to your app
      3. Turn off logging and debugging
      4. Internationalize and localize your app
      5. Improve error messages
      6. Test your app on different devices
      7. Provide proper feedback channels
      8. Reduce the size of your app
      9. Use the Android App Bundle
      10. Enable minification and obfuscation
    3. Releasing our app to the Google Play Store
      1. Creating our first release
    4. An overview of Google Play Store policies
    5. Summary
  23. Chapter 14: Continuous Integration and Continuous Deployment
    1. Technical requirements
    2. Setting up GitHub Actions
      1. Benefits of CI/CD
      2. How CI/CD works
      3. Setting up GitHub Actions
    3. Running lint checks and tests on GitHub Actions
    4. Deploying to Play Store using GitHub Actions
    5. Summary
  24. Chapter 15: Improving Your App
    1. Technical requirements
    2. Using Firebase Crashlytics to detect crashes
      1. Setting up Google Analytics
    3. Improving app engagement with Firebase Messaging
    4. Securing your app
    5. Summary
  25. Index
    1. Why subscribe?
  26. Other Books You May Enjoy
    1. Packt is searching for authors like you
    2. Download a free PDF copy of this book

Product information

  • Title: Mastering Kotlin for Android 14
  • Author(s): Harun Wangereka
  • Release date: April 2024
  • Publisher(s): Packt Publishing
  • ISBN: 9781837631711