Key Takeaways
Learn Kotlin by building one small app, not memorizing a language catalog.
Start with a working problem. The book teaches Kotlin by building a seven-day weather app, rather than presenting features in abstract chapters. The project begins with a list of sample forecasts, then grows to fetch real data, display details, save forecasts locally, and let users change the city. Each stage introduces language tools where they solve a concrete Android task.
Practice makes the syntax stick. The intended reader already knows basic Java and Android. Kotlin is presented as a practical next step: familiar enough to adopt gradually, but expressive enough to simplify everyday work. Readers are encouraged to follow the code in Android Studio, run it, and change it, not merely read the examples.
The project gives new syntax a job to do. A lambda is easier to remember when it replaces a click listener, and a data class makes sense when an API response needs a shape. This is a strong form of situated learning: knowledge is acquired alongside the context that makes it useful. The tradeoff is that a project can leave gaps in systematic coverage. Readers should treat the app as a guided apprenticeship, not a complete language reference.
Replace Java boilerplate with properties, defaults, and data classes.
Let the language carry routine work. Kotlin properties combine a field with accessor behavior, so callers can read `person.name` while custom getters and setters still control how that value is handled. Functions can provide default parameter values and accept named arguments, reducing the overloads that Java often needs. The compiler can also infer many types from their assigned values.
Use data classes for data. A Kotlin `data class` declares the properties that define an object, then generates useful methods such as `equals`, `hashCode`, and `toString`. It also provides `copy` for creating a revised instance and component functions for destructuring. A forecast can therefore be represented by its date, temperature, and description without hand-writing routine accessors and comparisons.
Less boilerplate can mean fewer places for defects to hide. Generated equality and hashing are especially useful because hand-written versions can quietly omit a field. Properties also make APIs easier to read without preventing encapsulation. Concision is not automatically clarity, though: a short declaration still deserves meaningful names, and generated behavior depends on which properties appear in the primary constructor. The useful test is whether the shorter code makes the model's intent more visible.
Make nullability visible, then design values to change less.
Put uncertainty in the type. In Kotlin, a type such as `Forecast?` explicitly permits a missing value, while `Forecast` does not. Code cannot use a nullable value as though it were guaranteed to exist. The safe-call operator performs an operation only when a value is present, and the Elvis operator supplies an alternative, such as a default value or an early return. A double-bang assertion can force access, but risks the runtime failure that null safety is meant to prevent.
Prefer stable references. `val` prevents reassignment, while `var` allows it. The book recommends using `val` when practical because fewer changing references make code easier to reason about, especially across threads. Data-class `copy` supports this style by creating a revised object instead of mutating the original.
Nullability is a compact form of documentation that the compiler can enforce. It moves a common failure from a possible runtime surprise into the design of the program. Immutability complements that guarantee by shrinking the number of state changes a reader must track. Neither is absolute protection: Java libraries can expose values with uncertain nullability, and an immutable reference can still point to a mutable object. Safe design therefore requires attention to the objects behind the type, not just the type declaration.
Use extensions and lambdas to express intent at the call site.
Put behavior near its use. An extension function adds a callable operation to an existing type without modifying that type's source code. The book uses this idea to create helpers such as a toast operation for Android contexts. Such functions can replace scattered utility calls with readable operations on the relevant object.
Pass actions directly. A lambda is an anonymous function that can be stored or passed as an argument. Kotlin can convert a lambda into an implementation when a Java API expects an interface with one method, as with a view click listener. The weather app's adapter can therefore accept a function that receives a forecast, rather than requiring a separate listener interface and anonymous class. Scope functions such as `with` help group several operations on one object.
These features reduce the distance between a call and its purpose. A click handler can show the action directly, while an extension can make a common operation read like part of the type's vocabulary. That is a genuine readability gain when helpers are small and consistently named. The risk is that extensions can create the illusion that a class itself changed, and layers of concise lambdas can obscure control flow. Good Kotlin style uses expressiveness to reveal the operation, not merely to compress it.
Keep API, domain, and database models separate, then map between them.
Give each layer its own shape. The weather API returns a large JSON structure with city details and many forecast fields. The app does not need every field in its interface, so the book parses the response into data classes, then maps the relevant information into simpler domain models. Database models serve a different purpose again, matching stored columns and identifiers.
Choose the source deliberately. A forecast provider checks its sources in order: first the local database, then the server. It accepts a result only if it contains enough current days. When the server supplies fresh data, the app converts and saves it, then reads it back from storage. This arrangement keeps networking, persistence, and display logic from becoming one activity-sized tangle.
Separate models are not needless duplication when they protect different boundaries. An API can change its naming or payload without forcing the user interface to inherit those decisions, and database identifiers need not dictate the shape of a screen. The provider's ordered lookup also makes the cache policy explicit rather than hiding it inside a request. The cost is mapping code and coordination between layers. That cost earns its keep when the boundaries isolate change; for a tiny throwaway app, a lighter structure may be enough.
Let collection operations say what a transformation means.
Describe the result, not the loop. Kotlin's collection functions express common tasks directly. `filter` selects elements matching a condition, `map` transforms each element, and `mapIndexed` also provides its position. In the app, forecast records are mapped into display-ready domain objects without manually building a second list and managing an index.
Compose operations with care. Other functions can count matches, group elements, sort them, or find the first suitable result. The book even adds a `firstResult` helper that searches data sources until one returns a non-null forecast. Kotlin also supports ranges and expressive `when` expressions, while generics let functions work across types. These tools reduce repetitive control flow, but each operation still has costs and behavior worth understanding.
A collection pipeline makes the transformation's shape visible: select, convert, and return. This is often easier to inspect than mutable accumulation spread across a loop. The approach also makes small operations reusable and testable. However, a chain of transformations can allocate intermediate collections, and a clever helper such as firstResult may conceal an exception when no source succeeds. The best choice depends on both readability and behavior. Concise code should make data movement easier to follow, not turn it into a puzzle.
Delegate repeated property behavior, but inspect Android lifecycle and caching.
Reuse property logic. A delegated property hands its getter or setter behavior to another object. Kotlin's standard delegates include `lazy`, which initializes a value on first access, and `observable`, which reacts to assignments. The book also builds a delegate for a Shared Preferences value, allowing a city zip code to be read and saved through property syntax. A custom delegate demonstrates how to enforce a value that can be assigned only once.
Know what the plugin generates. Kotlin Android Extensions lets code access views by their XML identifiers. Its generated cache works for activities and fragments, with fragment views cleared when destroyed. The book warns that view-based access in an adapter does not automatically use that cache, and demonstrates a `LayoutContainer` approach for a ViewHolder.
Delegation is valuable when several properties genuinely share the same policy, such as lazy initialization or preference storage. It turns repeated mechanics into a reusable abstraction and keeps callers focused on the value. Generated view access offers a similar convenience, but convenience can hide lifecycle and performance details. The book's bytecode inspection is a useful habit: abstractions are easier to trust when developers know what they produce. Android tooling has changed since this edition, so its specific plugin instructions should be read as historical examples, not current setup advice.
Write asynchronous flows in sequence without forgetting activity lifetimes.
Keep the logic readable. The sample first uses Anko's `doAsync` to perform a network request off the main thread, then returns to the UI thread to update the screen. It also introduces coroutines, which let asynchronous work be written in a sequential style. In the example, a background operation returns a deferred result, and the UI flow waits for that result before binding the forecast.
A readable flow still has a lifetime. The book points out that an asynchronous block can retain a reference to an activity after Android has destroyed it. Anko offers a weak-reference approach, but the text notes that its extra complexity may not be worthwhile for a short, bounded request. The key is to keep blocking work away from the UI and reason about what happens if the screen disappears.
Sequential syntax can make asynchronous dependencies easier to understand because the code reads in the same order as its results are needed. But syntax does not solve lifecycle management by itself. A request can outlive the screen that started it, and updating a destroyed activity remains a design problem even when callbacks disappear. The book usefully refuses to treat a convenient API as magic. Its coroutine examples reflect an experimental Kotlin era, so their particular library calls should not be mistaken for a timeless Android prescription.
Inject collaborators so tests can replace servers, databases, and providers.
Make dependencies swappable. Instead of constructing every collaborator inside a class, the app can accept dependencies through its constructor. Default arguments keep ordinary use simple, while tests can pass a fake or mock. The forecast provider, for example, accepts a list of data sources, making it possible to check how it behaves when one source has no result and another does.
Test at the right boundary. The book demonstrates local unit tests for functions that do not require Android, and instrumentation tests for interactions that need a running app, such as selecting a forecast or changing the city code. It also shows a practical complication: Kotlin classes are closed by default, which can prevent some mocking tools from substituting them unless the class is opened, abstracted behind an interface, or supported by an appropriate mocking configuration.
Constructor injection makes tests possible by making hidden dependencies explicit. It also clarifies what a class needs in order to do its work, a benefit that lasts beyond testing. The distinction between local and device-based tests is equally important: fast tests can cover transformations and decision rules, while UI tests verify the integration that pure tests cannot. Mocking should not become the only way to test design, however. When a class is difficult to exercise without extensive simulation, that friction can signal that responsibilities are too tightly coupled.
Adopt Kotlin alongside Java, while respecting the interop boundary.
Migrate without a rewrite. Kotlin and Java can coexist in one Android project, so a team can write new features in Kotlin while retaining existing Java code and libraries. Kotlin can call Java getters and setters through property syntax, and Java can call many Kotlin functions through generated classes and methods.
The boundary is not invisible. Kotlin extension functions appear to Java as static functions whose receiver becomes an argument. Default arguments are not automatically available as Java overloads unless generated overloads are requested. Some features, including reified generic functions, cannot be called from Java in the same way. The book's practical message is to use Kotlin incrementally, while checking how features appear to Java callers.
Interoperability changes adoption from a high-stakes rewrite into a series of smaller choices. That lowers organizational risk and lets teams learn while maintaining working software. Yet a mixed-language codebase has two audiences: Kotlin callers and Java callers. An API that feels elegant in one language may be awkward in the other, so public boundaries deserve deliberate design. The most sustainable migration is not necessarily the fastest conversion. It is the one that preserves understandable interfaces while allowing each new piece of Kotlin to earn its place.
Analysis
This is both a Kotlin primer and a worked argument for learning languages through the problems they solve. Its weather app supplies a narrative spine: data arrives from an API, becomes usable domain objects, appears in a list and detail screen, persists locally, and responds to a changed setting. That progression gives otherwise disconnected features a reason to exist. Data classes address model boilerplate; nullability changes how missing data is represented; lambdas simplify event handling; and dependency injection makes the provider testable.
The book's most durable lesson is not any single syntax feature. It is that Kotlin's expressiveness matters when paired with boundaries: separate data representations, keep UI work distinct from network and storage work, and expose dependencies where they can be replaced. Extension functions and delegates are strongest when they make those boundaries clearer. They are weaker when convenience obscures generated behavior or lifecycle assumptions.
The source is a 2018 edition, written around Kotlin 1.1 and the Android tools of that period. Some named libraries, plugin mechanisms, Gradle conventions, and coroutine APIs are historically specific and should not be copied into a current project without checking contemporary documentation. That age does not erase the core ideas, but it changes the book's role: it is a clear account of Kotlin's design advantages and a practical learning model, not a current Android implementation manual. The app is intentionally modest, too. Its architecture is useful as a teaching scaffold, not proof that every application needs the same number of layers.
Review Summary
Kotlin for Android Developers receives mixed reviews. Many praise its hands-on approach and effectiveness in teaching Kotlin for Android development. Readers appreciate the practical examples and comparison with Java. However, some criticize the book's organization, lack of clear code placement instructions, and outdated content. The GitHub repository's usefulness is debated. Despite these issues, many find it a good introduction to Kotlin, especially for those with Android development experience. The book's concise nature and friendly writing style are highlighted as positives.
People Also Read
Glossary
data class
Data-focused classA Kotlin class intended primarily to hold values. The compiler generates methods based on properties in its primary constructor, including equality, hashing, string representation, copying, and component functions used for destructuring. In the book's weather app, data classes represent API responses and domain forecasts without hand-written accessor and comparison code.
Extension function
Adds callable behaviorA function declared with a receiver type, making it callable with the syntax of a member on that type even though the original class is not modified. It is useful for adding focused helpers to existing or third-party types. From Java, an extension function is generally accessed as a static function with the receiver passed as an argument.
Delegated property
Outsourced property behaviorA property whose getter and, when applicable, setter delegate their work to another object. Kotlin uses the by syntax to connect the property to that behavior. Delegates can provide reusable policies such as lazy initialization, change observation, or reading and writing a value in Android Shared Preferences.
Smart cast
Compiler-narrowed typeA Kotlin compiler feature that treats a value as a more specific, non-nullable type after a successful type or null check, when the value cannot have changed in a way that invalidates the check. It removes repeated casts and null assertions inside the checked scope while preserving the declared type elsewhere.
Coroutine
Lightweight asynchronous computationA mechanism for structuring asynchronous work so that operations that wait can suspend and resume without requiring a separate thread for every task. Kotlin's coroutine feature relies on suspending functions, which run within a coroutine context. The book's examples use Anko's then-experimental Android support to perform background work and return results to the UI.
Variance
Controls generic type flexibilityRules that determine whether a generic type using one type argument can be used where a related type argument is expected. Kotlin supports declaration-site variance: out marks a type as producing values and permits covariance, while in marks a type as consuming values and permits contravariance. These annotations constrain how the generic type can be used.
Reified type
Available generic type at runtimeA generic type parameter made available inside an inline Kotlin function, allowing the function to use the actual type where ordinary generic type information is not available in the same way. The book uses this idea to simplify Android activity navigation. Reified functions are a Kotlin feature and are not directly available to Java callers.
Anko
Kotlin Android helper libraryA JetBrains library used in the book to simplify common Android tasks through Kotlin extensions and helper APIs. Examples include asynchronous work, database access, context and view helpers, and activity navigation. The book treats Anko as a way to study how Kotlin features support Android development; its examples reflect the library and ecosystem available when the book was written.
Kotlin Android Extensions
Generated Android view accessA Kotlin plugin feature described in the book that exposes Android XML views through properties named after their resource identifiers. The generated access code can include a cache for activities and fragments, with fragment view caches cleared when the view is destroyed. The plugin's behavior and setup instructions are specific to the book's historical toolchain.
Download PDF
Download EPUB
.epub digital book format is ideal for reading ebooks on phones, tablets, and e-readers.