Start free trial
Trending New Genres Authors
EnglishEnglish
EspañolSpanish
简体中文Chinese
繁體中文Chinese (Traditional)
FrançaisFrench
DeutschGerman
日本語Japanese
PortuguêsPortuguese
ItalianoItalian
한국어Korean
РусскийRussian
NederlandsDutch
العربيةArabic
PolskiPolish
हिन्दीHindi
Tiếng ViệtVietnamese
SvenskaSwedish
ΕλληνικάGreek
TürkçeTurkish
ไทยThai
ČeštinaCzech
RomânăRomanian
MagyarHungarian
УкраїнськаUkrainian
IndonesiaIndonesian
DanskDanish
SuomiFinnish
БългарскиBulgarian
עבריתHebrew
NorskNorwegian
HrvatskiCroatian
CatalàCatalan
SlovenčinaSlovak
LietuviųLithuanian
SlovenščinaSlovenian
СрпскиSerbian
EestiEstonian
LatviešuLatvian
فارسیPersian
മലയാളംMalayalam
தமிழ்Tamil
اردوUrdu
Searching...
SoBrief
Kotlin for Android Developers

Kotlin for Android Developers

Learn Kotlin the easy way while developing an Android App
Build a weather app while learning Kotlin, and see how it can simplify everyday Android development.
by Antonio Leiva 2016 240 pages
3.85
183 ratings
Listen
Immersive
V2.3
Amazon Kindle Audible
Try Full Access for 3 Days
Unlock listening & more!
Continue

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.

Analysis

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.

Analysis

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.

Analysis

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.

Analysis

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.

Analysis

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.

Analysis

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.

Analysis

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.

Analysis

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.

Analysis

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.

Analysis

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.

Summary in 30 Seconds
Kotlin reduces routine Java code with properties, default arguments, and data classes. Nullable types make missing values explicit, while immutable references limit accidental changes. Extensions, lambdas, and collection operations clarify common tasks, but generated behavior and Android view lifecycles still need scrutiny. Separate network, domain, and storage models, inject data sources for testing, and keep asynchronous work mindful of screen lifetimes. Kotlin can join an existing Java project, though some language features cross that boundary imperfectly.
Contains spoilers

Last updated:

Report Issue

Review Summary

3.85 out of 5
Average of 183 ratings from Goodreads and Amazon.

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.

Your rating:
4.38
131 ratings
Want to read the full book?

Glossary

data class

Data-focused class

A 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 behavior

A 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 behavior

A 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 type

A 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 computation

A 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 flexibility

Rules 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 runtime

A 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 library

A 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 access

A 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.

About the Author

Antonio Leiva is a software developer and author specializing in Android development. He wrote Kotlin for Android Developers to introduce Kotlin programming in the context of Android app creation. Leiva's approach focuses on practical, hands-on learning, demonstrating Kotlin's advantages over Java 7 for Android development. His book covers essential components of real-world Android apps, including UI, REST, database interactions, and testing. Leiva's work aims to bridge the gap between traditional Java-based Android development and the more modern Kotlin approach. Despite some criticism of the book's organization, Leiva's expertise in both Kotlin and Android development is evident throughout the text.

Download PDF

To save this Kotlin for Android Developers summary for later, download the free PDF. You can print it out, or read offline at your convenience.
Download PDF
File size: 0.31 MB     Pages: 18

Download EPUB

To read this Kotlin for Android Developers summary on your e-reader device or app, download the free EPUB. The .epub digital book format is ideal for reading ebooks on phones, tablets, and e-readers.
Download EPUB
File size: 1.35 MB     Pages: 19
Want to read the full book?
Follow
Listen
Home
Swipe
Library
Get App
Try Full Access for 3 Days
Listen, bookmark, and more
Compare Features Free Pro
📖 Read Summaries
Read unlimited summaries. Free users get 3 per month
🎧 Listen to Summaries
Listen to unlimited summaries in 40 languages
—
❤️ Unlimited Bookmarks
Free users are limited to 4
—
📜 Unlimited History
Free users are limited to 4
—
📥 Unlimited Downloads
Free users are limited to 1
—
Risk-Free Timeline
Today: Get Instant Access
Listen to full summaries of 26,000+ books. That's 12,000+ hours of audio!
Day 2: Trial Reminder
We'll send you a notification that your trial is ending soon.
Day 3: Your subscription begins
You'll be charged on Nov 24,
cancel anytime before.
Consume 2.8× More Books
2.8× more books Listening Reading
Our users love us
1M+ readers
Trustpilot Rating
TrustPilot
4.6 Excellent
This site is a total game-changer. I've been flying through book summaries like never before. Highly, highly recommend.
— Dave G
Worth my money and time, and really well made. I've never seen this quality of summaries on other websites. Very helpful!
— Em
Highly recommended!! Fantastic service. Perfect for those that want a little more than a teaser but not all the intricate details of a full audio book.
— Greg M
Save 62%
Yearly
$119.88 $44.99/year/yr
$3.75/mo
Monthly
$9.99/mo
Start a 3-Day Free Trial
3 days free, then $44.99/year. Cancel anytime.
Unlock a world of fiction & nonfiction books
26,000+ books for the price of 2 books
Read any book in 10 minutes
Discover new books like Tinder
Request any book if it's not summarized
Read more books than anyone you know
#1 app for book lovers
Lifelike & immersive summaries
30-day money-back guarantee
Download summaries in EPUBs or PDFs
Cancel anytime in a few clicks

Why one summary?

Scanner
Find a barcode to scan

⭐
⭐
⭐
We have a special gift for you
Open
38% off
DISCOUNT FOR YOU
⭐
⭐
⭐
$79.99
$49.99/year
Only $4.16 per month
Continue
2 taps to start, super easy to cancel
Settings
General
Widget
Loading...