Ever since its inception, Android development has been known for being just as frustrating, as it is fun! Developing Android apps involves not only juggling an ever-changing framework, but also handling interesting and challenging design decisions.
With such a large, continuously mutating ecosystem, developing even the simplest of features can feel overwhelming for beginners — and, sometimes, even for advanced developers. Professional Android developers need to know about a wide array of subjects to build apps effectively.
That’s why we’re really excited to announce that our newest book, Real-World Android by Tutorials, is now out today! It’s designed to go beyond the basics, and, as the name implies, give you practical solutions to the real-world problems faced by developers every day.
Keep reading to see what’s inside, and how you can get your copy today!
What is Real-World Android by Tutorials?
Real-World Android by Tutorials is designed to go beyond the code and understand why you’re writing it in the first place. This book doesn’t simply cover the basics at the problem’s surface, or give high-level descriptions of the simplest use cases.
Rather, it aims to share with you some of the knowledge that developers acquire over time, while developing real-world apps. You’ll see how to solve real-world problems by following real-world best practices and techniques that you can only acquire by rolling up your sleeves and working through the problem yourself.
The book focuses not only on why should you do things a specific way, but also on the corresponding advantages, trade-offs and drawbacks of that solution. It makes it clear when a certain decision is not ideal, explaining the reasoning behind discarding a choice or going through with it anyway.
As you go through the content, you might notice that some of it is opinionated; you might even disagree with some of the statements. That’s good! As a developer, it’s only natural for you to question other developers’ decisions. You might even see some problems that others completely missed.
On the other hand, if you agree with everything and don’t see any problems, that’s fine too! What’s important here is for you to go through the roller coaster ride that is Android, with all is ups and downs, just like developers do in the real world.
Who is this Book For?
This book is useful for developers of all levels. Some of the content assumes prior knowledge of complex topics, like RxJava and Dagger, and is more tailored to intermediate or advanced developers. But there’s plenty of content suitable for less-experienced developers as well.
A large part of the book’s focus is around the reasons why developers prefer specific solutions. This usually boils down to software design principles, architectural considerations or tidbits of wisdom acquired through experience. In these cases, everyone can benefit from this information — no matter how far along you are in your Android career.
What’s Inside Real-World Android by Tutorials?
This book covers a lot of topics. You’ll build features in scalable ways, modularize your app, handle animations, styles, themes and other elements of the UI with ease, secure your apps in a responsible manner, plan for maintenance and aftercare of your app, and so much more.
It does all of this by showing you practical solutions that lead to the desired results. Yet, the idea here is much more than that. Of course, you can study the implementation details if you want, but that’s not the main point. Instead of reasoning about how to write code, you should instead focus on why you write it that way.
Real-World Android by Tutorials takes you from beginner to expert over 22 massive chapters, spanning five sections:
Section I: Developing Real World Apps
In this section, you’ll learn how to design and implement PetSave as an example of a professional, real world app. You’ll learn how to choose the right architectural pattern and how to structure the code to make the app testable and maintainable.
To make your app easier to change, it’s a good practice to define different layers with specific responsibilities. In particular, you’ll learn how to design and implement the domain layer for the PerSave app. You’ll also see how to access the network efficiently, by implementing the repository pattern in the data layer.
At the end of this section, you’ll have a clear idea about how to structure the code of your app.
- Introduction: The Android platform is more than 10 years old and the number of frameworks, libraries and tools you can use to develop your app are countless. This book covers the technologies and practices you need to follow in the real world if you want to create a successful Android app.
- Starting from the Beginning: Building Android apps isn’t just a matter of writing code. You also need to use the best architecture and structure your files in a way that makes it easy to apply changes. Keeping high cohesion and low coupling is just one of the main principles you’ll learn in this chapter, where you’ll start working on the PetSave app.
- Domain Layer: The domain layer is a collection of entity objects and related business logic, designed to represent the business model of any app. Here, you’ll learn what a domain layer is and how to create a good one. You’ll see the differences between entity and value objects along with the advantages of using the repository abstraction. Finally, you’ll test the domain logic of your app.
- Data Layer — Network: Every useful app allows users to access information that’s either stored locally or fetched from the network. This is what a data layer helps you do. In this chapter, you’ll learn what the data layer is and what choices you have when you need one. You’ll be introduced to the repository pattern and learn how to implement it from the design to the testing phase.
- Data Layer — Caching: Most apps access data from the network, which introduces different kinds of problems, like latency and connectivity costs. To improve performance and reduce costs, it’s a good practice to store data locally. Therefore, you need to implement the repository pattern as a cache or simple local store. In this chapter, you’ll learn how to implement and test the repository pattern in the PetSave app using Room and Hilt.
- Building Features — Animals Near You: PetSave allows users to find animals close to them based on certain criteria. There are several architectural design patterns you can use to create this feature. Here, you’ll use ModelViewViewModel (MVVM) to implement the “Animals Near You” feature. You’ll also have the opportunity to learn how to use fundamental libraries like LiveData, ViewModel and ViewBinding.
- Building Features — Search: PetSave’s main feature is to let you search for pets based on certain criteria. In this chapter, you’ll use a top-down approach to implement the search, from defining the UI to fetching the data.
Section II: Modularizing Your App
As you add new features to your app, the code becomes more complex and difficult to maintain. For this reason, it’s important to separate your app into different libraries to make your code both maintainable and reusable. This also improves the app’s build time, which is a very important metric for your CI.
In this section, you’ll learn how to split your app into different modules. In particular, you’ll learn how to use the dynamic feature option, which optimizes the size of the code your users have to download to use your app.
- Multi-Module Apps: Modularization is one of the most challenging problems you face with big apps. Splitting the app into different modules lets you reduce build time while creating code you can reuse in other apps. In this chapter, you’ll learn how to create a feature module for PetSave, focusing on the navigation.
- Dynamic Features Theory: This chapter covers the fundamental concepts of dynamic features. Dynamic features let you split the app into different modules to reduce the APK size and the download time and cost.
- Building a Dynamic Feature: Mobile apps, especially games and apps with lots of graphic assets, often have large APKs. Google’s dynamic feature option lets you keep your app sleek by splitting it into parts that users can load if and when they actually need them. In this chapter, you’ll learn how to use dynamic features to install PetSave more efficiently.
Section III: Enhancing Your UI
The user interface (UI) is one of the most important aspects of any real world app. How your user interacts with the features of your app is what decides if the app is successful or not.
When you build your app, you have three options for creating your UI. Most of the time you’ll use what the Android SDK provides. In other cases, you customize the existing components. Your third option is to create your own custom components.
In this section, you’ll learn how to enhance the user interface of your app. You’ll create and customize animation using the new Animation Editor, which comes with recent versions of Android Studio. You’ll also learn how to master themes and styles and to create a custom view.
After reading this section, you’ll have a more appealing app and happier users.
- Animations: Animations are vital to making your app both easy and pleasant to use. The Android platform provides several APIs to implement different types of animations. In this chapter, you’ll learn how to use both physics-based and Lottie animation.
- MotionLayout & Motion Editor: Implementing animation in the Android platform can be difficult and time-consuming. It’s very important to use the right tool. In recent releases of Android Studio, the Motion Editor lets you implement different types of animations in a simple and declarative way. In this chapter, you’ll learn how to use Motion Editor and how to integrate MotionLayout into your app.
- Custom Views: The Android platform provides different standard components you can use to create the UI for your app. Most of the time, they’re enough. Sometimes, as in the PetSave app, you need something custom. To create custom UI elements, you use the custom view, which you’ll learn all about in this chapter.
- Style & Theme: Android provides styles and themes to customize the look and feel of the UI components of any app. They allow you to completely change any aspect of the UI of your app in a declarative way by providing a simple XML file. In this chapter, you’ll see how to customize a UI that uses standard components and how to use styles and themes with a custom view.
Section IV: Securing Your App
Making your app more secure is an aspect of development that’s often ignored, but, at the same time, is absolutely vital. Imagine what would happen if somebody would hack your code, stealing important data or even the usernames and passwords of your users. That would be a disaster.
In this section, you’ll learn how to handle security from different points of view. You’ll learn how to protect user data and how to securely connect to a server. Finally, you’ll learn how to make hackers’ lives more difficult, by using different methods to protect your code and your data.
- User Privacy: In this chapter, you’ll learn best practices for securing an Android app. You’ll see how to deal with permissions and how to prevent the most common security risks.
- Securing Data at Rest: Accessing data from local storage has security implications, so Android provides different APIs and tools to avoid unwanted access to your data. Here, you’ll learn how to make your app more secure by encrypting and decrypting data and by using biometrics to implement the user login.
- Securing Data in Transit: In this chapter, you’ll learn to secure the network connections of your app by using HTTPS for network calls, trusting a connection with certificate pinning and verifying the integrity of transmitted data.
- App Hardening: Any mobile app can be vulnerable to different types of attacks from hackers. It’s common to read about hackers breaking apps and stealing important information. Because of this, avoiding code vulnerability and validating the input from the user are very important topics. In this chapter, you’ll learn how to use some of the most important techniques to make your app difficult to hack.
Section V: Maintaining Your App
When you’re developing your real world app, you might think that publishing is your end goal. But really, your work isn’t over just because you’ve released your app. You still need to understand if your app is working properly and what problems your users are experiencing.
In this section, you’ll learn everything you need to know about maintaining and controlling your app after it’s published and available to users. In particular, you’ll learn how to use Firebase for logging crashes, how to enable or disable certain features and how to use A/B tests to understand what solution is the best for your users.
Finally, you’ll see how to optimize your app’s size and how to use Android Studio as a profiling tool.
After reading this section, you’ll be ready to use all the available tools for improving your app’s quality.
- Firebase Integration: Firebase is a powerful tool to manage important aspects of your app. Here, you’ll see how to use Crashlytics to monitor crashes and errors. Then, you’ll see how to use Remote Config to control your app remotely. Finally, you’ll learn how to use Test Lab to test your app on a wide range of devices.
- Release Optimizations: When you build an app, it isn’t enough to implement its features and run tests. You also need to spend time improving your app’s quality through optimization. For example, reducing the APK’s size is important to support old devices and users with slow internet connections. In this chapter, you’ll learn how to optimize your app before release.
- Advanced Debugging: When you implement an app or try to fix a bug, you need some tools to check what’s happening. For example, you experience a crash and don’t know why, or you receive invalid information from the network and need to check the data. This chapter contains everything you need to know about debugging, from memory to network, from battery usage to the definition of the UI and much more.
- App Analysis: Sometimes, your app has problems and you don’t know why. To solve the problem, you need to do some deep investigation, not just into your code but also into code you imported from third-party libraries. In other cases, the problem isn’t the code, but a corrupted file or database. In this chapter, you’ll learn how to examine the bytecode of your app and the files it uses to find bugs and security problems.
About the Authors
Of course, our book would be nothing without the real-world skills of our real-world authors:
Ricardo Costeira is an Android dev with a crush on clean code and software architecture. Based in Portugal, Ricardo works as a senior Android engineer at Mindera, where he builds and maintains a retailer app with tens of thousands of daily active users. Ricardo loves Android and the community, so it’s only natural that he tries to have an active part in it! He’s a co-organizer of GDG Coimbra and a co-founder of Kotlin Knights. He occasionally writes (mostly about Android) at his site, ricardocosteira.com, or for raywenderlich.com. He loves cats, food and the gym and he’s a specialty coffee hobbyist. You can find him on Twitter at @rcosteira79.
Subhrajyoti Sen is an Android Engineer at KeepTruckin, where he develops apps to improve the trucking industry. Before that, he also worked on apps to improve the experience of Indian investors. He believes in the power of open source and communities, and actively tries to give back. When not writing code, you can find him binge-watching anime, reading up on public policy or playing Rocket League.
Kolin Stürt is a software team lead with a focus on encryption, reverse-engineering, forensics and application hardening. He’s worked on many platforms, most notably Android, iOS and Linux. He has an interest in networking and has been hacking and developing apps since 2009. Outside of cybersecurity, he composes and performs music, as well as practicing and holding a black belt in Aikido. You can find him at https://kolinsturt.github.io.
Where to Go From Here?
Real-World Android by Tutorials is out today — and even better, you can start reading the entire first section for free here:
Like every one of our books, Real-World Android by Tutorials has been automatically added to the collections of all Ultimate Pro subscribers!
Want your own copy of Real-World Android by Tutorials? There are two ways you can enjoy this book:
- Buy it individually: If you want to build up a custom library without a subscription, you can choose to buy the book individually. It’s available now for just $59.99 in our online store.
- Get it as part an Ultimate Pro book and video subscription: Enjoy access to our videos and mobile development books in our Ultimate Pro subscription, including SwiftUI by Tutorials! Right now, you can get a full year’s Ultimate Pro subscription and save 20% off the cost of a regular monthly subscription. It’s simply the best investment for your mobile development career.
We hope you enjoy Real-World Android by Tutorials; it’s been written by professionals like you, for professionals like you. On behalf of the book team, thank you for your support!