All bites
The whole library, newest first. Filter by what you are here for, or pick a topic if you already know.
4247 bites
Page 192

StateFlow: A Hot Flow for UI State
StateFlow is a state-holder observable that emits the current and new state updates to its collectors. Use it to expose UI state from a ViewModel to a UI. The footgun: slow collectors can miss intermediate state updates, receiving only the most recent value.

Kotlin Delegated Properties: Reusing Getter/Setter Logic
Kotlin's delegated properties let you outsource a property's getter/setter logic. Instead of writing boilerplate, you reuse common patterns like lazy initialization (by lazy) or observing changes (by observable).

Coroutine Exception Handling: launch vs. async
Coroutine builders handle exceptions differently. launch propagates them immediately, crashing if unhandled. async silently catches them, waiting for you to call await. Use a CoroutineExceptionHandler on root scopes for global logging.

SharedFlow: A Hot Flow for Broadcasting Events
A SharedFlow is a hot stream that broadcasts values to all subscribers, like a live TV channel. It's ideal for one-to-many events, like UI updates or notifications. The main footgun: it never completes, so collect will suspend forever.

Kotlin's `in` and `out`: Declaration-Site Variance
Kotlin's out and in keywords define a generic class as a producer or consumer at its declaration, avoiding Java's repetitive wildcards. Use out T for types only returned (produced) and in T for types only consumed.

Reified Type Parameters: Accessing Generic Types at Runtime
Reified type parameters let you access generic types at runtime, bypassing JVM type erasure. In Kotlin, you use this inside inline functions to check types (obj is T) or get a class reference. The footgun: reified requires inline to work.

Kotlin's Type-Safe Builders: Code as Data
Type-safe builders use Kotlin code to create a custom language (DSL) for building complex objects. It's like writing HTML, but the compiler validates your structure. This is common for UI layouts or server configs. The footgun is omitting @DslMarker.
Android Studio: The Official Workshop for Android Apps
Think of Android Studio as the all-in-one workshop for building Android apps. It bundles a code editor, build system, and emulators to write, test, and package software for any Android device. The footgun is underestimating its resource needs.

Android Project Structure: Your App's Filing Cabinet
Think of an Android project as a standardized filing cabinet. It organizes your code, images, and configuration into specific folders so the build system knows where to find everything. This is the foundation of every Android app you build or inspect.

AndroidManifest.xml: The Blueprint for Your App
AndroidManifest.xml is the blueprint for your app, telling the OS its components, permissions, and requirements before running any code. A missing declaration here is a common source of runtime crashes, as the OS simply won't see your component.

Android App Development: Core Languages and Tools
Android apps are primarily built with Kotlin, Java, and C++ using the official SDK. While other languages are possible, they often need 'glue' code to work and may have restricted API access. The main footgun is assuming any language has first-class support.

Logcat: The `tail -f` for Android Apps
Think of Logcat as tail -f for your Android app, streaming system and application messages from a device in real-time. It's your primary tool for debugging crashes, tracking execution flow, and inspecting variable values as your app runs.

Adding Build Dependencies with Gradle in Android
Gradle is the tool for adding build dependencies to your Android app. This allows you to integrate external libraries like Jetpack, Compose, or Google Play Services, which are essential for building modern applications.

Android Build Variants: One Codebase, Many Apps
Think of build variants as a matrix for your app builds, combining build types (like debug/release) with product flavors (like free/paid). This lets you manage different API endpoints or features for various versions from a single codebase.

Android Debug Bridge (ADB): A Developer's Remote Control
Android Debug Bridge (ADB) is a developer's universal remote for an Android device. This command-line tool lets you install apps, view logs, and run shell commands, bypassing the UI. It's used for debugging, file transfers, and automation.
Android Gradle Plugin (AGP): The Engine of Your Android Build
The Android Gradle Plugin (AGP) is the specialized toolkit that teaches Gradle how to build, test, and package Android apps. It's used in every project to handle tasks like compiling resources and signing your app.

Android Studio Profiler: Find Your App's Bottlenecks
The Android Studio Profiler is your app's diagnostic dashboard, showing real-time CPU, memory, and network usage. Use it to hunt down UI jank, find memory leaks, and optimize battery-draining network calls.

Layout Inspector: Debug Your UI Hierarchy
Layout Inspector is an X-ray for your app's UI, rendering a live 3D model of your component tree. Use it to debug visual glitches or find performance bottlenecks from deep layouts. The footgun is forgetting it has live updates to catch bugs during animations.

R8: Shrinking and Obfuscating Android Code
R8 is a compile-time tool that shrinks and obfuscates your Android app. It removes unused code and renames classes to reduce APK size and deter reverse-engineering.

Android Activity: A Single Screen in Your App
An Android Activity is the window for a single screen in your app where users interact with your UI. The OS manages a "back stack" of Activities; starting a new screen pushes one on, and pressing back pops it off.