Mobile & Android
Android libraries, Flutter, Kotlin and Swift. 80 posts, newest first. All topics
Last Light Outpost: a Godot zombie base-defense game for Android and the browserLast Light Outpost is a top-down zombie base-defense game in Godot 4.7: its wave rules, code-drawn art, twin-stick touch controls and the Android build on Google Play.
Meridian: an offline tasks, habits and focus app for Android and the webHow Meridian works: one JSON document in localStorage, a quick-add parser, forgiving habit scores, AES-GCM locked notes and a Capacitor build for Google Play.
Afterlight on Android: touch controls and a Capacitor shell for a keyboard JRPGPorting the three.js JRPG Afterlight to Android: on-screen controls that press the same actions as the keyboard, a scaled desktop layout, and a signed Play bundle.
StateFlow and SharedFlow in Kotlin for Android UI stateHot and cold flows, StateFlow for screen state, SharedFlow for one-off events, stateIn with WhileSubscribed(5000), repeatOnLifecycle, and testing with runTest.
State Management in Flutter with Riverpod 3Riverpod 3 for Flutter apps: providers, ConsumerWidget, ref.watch versus ref.read, Notifier and AsyncNotifier, optional code generation, and tests with ProviderContainer.
SwiftUI's @Observable Macro: Moving Off ObservableObjectHow the Observation framework changes SwiftUI state: @Observable instead of ObservableObject and @Published, @State for owned models, @Bindable and typed @Environment.
State in Jetpack Compose: remember, State Hoisting and ViewModelHow state works in Jetpack Compose: remember and rememberSaveable, stateless composables, state hoisting, and a ViewModel StateFlow collected with lifecycle awareness.
Android Room basics: entities, DAOs and a database in KotlinHow to set up Android's Room library with KSP, define an entity, DAO and database, and read and write data from an Activity with coroutines and Flow.
ButterKnife on Android: binding views and click listeners, and migrating to View BindingHow ButterKnife's @BindView and @OnClick annotations work, the setup gotchas on current Android Gradle Plugin versions, and the View Binding code that replaces them.
Publishing a Swift package: SwiftPM, Git tags and the Swift Package IndexCreate a Swift package with SwiftPM, tag a semantic version, push it to a public Git repository, and list it on the Swift Package Index so others can depend on it.
Swift closures: syntax, capturing values, escaping and autoclosuresHow Swift closures work: the short syntax forms, trailing closures, how values are captured, @escaping, retain cycles with [weak self], and @autoclosure.
Access control in Swift: private, fileprivate, internal, package, public and openSwift's six access levels (private, fileprivate, internal, package, public, open), what each one allows, and the defaults and rules that trip people up.
Adding a Google Map with a marker to an Android appSet up a Maps SDK for Android API key, add the play-services-maps dependency, and show a map with a marker using SupportMapFragment in Java.
Swift memory management: ARC, reference cycles and exclusive accessHow Automatic Reference Counting frees Swift class instances, how to break reference cycles with weak and unowned, and what exclusive access and actors protect against.
Using Alamofire, RxSwift and SwiftyJSON in a Swift projectHow to add Alamofire, RxSwift and SwiftyJSON with Swift Package Manager, with a working example of each and when Apple's built-in APIs are the better choice.
Type casting in Swift: is, as, as? and as!How Swift's is, as, as? and as! operators work: upcasting, conditional and forced downcasting, casting in switch statements, and casting from Any and to protocols.
Mixing Swift and Objective-C: bridging headers and the generated Swift headerHow to call Objective-C from Swift with a bridging header, call Swift from Objective-C through the generated -Swift.h header, and how types bridge.
Creating, testing and publishing a Swift package with SwiftPMCreate a Swift library with swift package init, understand the Package.swift manifest, add a dependency, build and test it, and publish versions with Git tags.
Abstract classes vs interfaces in KotlinHow abstract classes and interfaces work in Kotlin, when to use each, and how open, override and super fit together.
Kotlin OOP basics: classes, properties, constructors, inheritance and polymorphismKotlin classes and objects, companion objects, properties and backing fields, primary and secondary constructors, inheritance with open, and polymorphism.
Reflection and annotations in Kotlin: reading properties and custom annotationsHow to inspect a class at runtime with Java reflection and kotlin-reflect, and how to declare, apply and read your own annotations in Kotlin.
Dart functions on Appwrite: base64 encode, HTTPS check and email slicerThree small Dart functions (base64 encoder, HTTPS URL check, email slicer) and how to run them as Appwrite Functions with the current context API.
Swift concurrency basics: async/await, actors, task groups and cancellationSwift concurrency with working examples of async/await, actors, task groups, and cancellation, including a timeout helper and common gotchas.
Espresso UI tests on Android: setup, matchers, idling resources and intentsHow to set up Espresso with AndroidX Test, write a UI test with ActivityScenarioRule, handle background work with idling resources, and verify intents.
Swift package conventions: layout, access control, tests and versioningPractical conventions for Swift packages: naming, layout, access control including package, DocC comments, tests, semantic versioning and a clean Package.swift.
RxJava 3 on Android: observables, operators and threadingHow RxJava 3 models async work on Android: Observable, Single and friends, common operators, schedulers, Retrofit integration, and disposing subscriptions.
Google Analytics on Android: the legacy v4 SDK and moving to FirebaseWhat Google Analytics v4 SDK code for Android looks like, why it no longer works, and how to replace trackers and hits with Google Analytics for Firebase.
Mockito for Android unit tests: mocks, stubbing, and verificationUse Mockito 5 in Android unit tests: create mocks, stub return values, verify calls, use argument matchers and answers, and mock final classes.
Retrofit on Android: calling a REST API from JavaSet up Retrofit in an Android app, define an API interface, make an async call with enqueue, and share one OkHttpClient for caching, auth headers and pooling.
Dagger 2 on Android: components, modules, scopes and a working setupHow Dagger's components, modules, @Inject constructors and scopes fit together, with a working Java example for an Android app and when to use Hilt instead.
Swift standard library basics: numbers, strings, collections and algorithmsA tour of Swift's standard library: integer and floating-point types, String and Character, Array, Set and Dictionary, and sorted, filter, map and reduce.
Building a Chrome extension in Flutter to view my ChatGPT promptsA Flutter web app packaged as a Manifest V3 Chrome extension popup that fetches a markdown file of ChatGPT prompts from GitHub and renders it.
Firebase Realtime Database on Android: setup, reads, writes and security rulesAdd Firebase Realtime Database to an Android app with the Firebase BoM, write and listen for data in Java, enable offline persistence, and lock it down with rules.
Places SDK for Android: nearby search, place details, autocomplete, and photosSet up the Places SDK for Android with Places API (New), then run a nearby search, fetch place details, show autocomplete predictions, and load place photos in Java.
Swift for mobile apps: strengths, drawbacks and when to pick something elseThe practical pros and cons of Swift for mobile development: safety, Apple tooling, Objective-C interop, Android support, and language churn.
Swift enums: cases, associated values, raw values, and switchHow Swift enums work, covering basic cases, associated values, raw values, switch pattern matching, CaseIterable, and adding methods to an enum.
The Android Support Library: what it did and how to move to AndroidXWhat the Android Support Library provided, how its artifacts map to AndroidX and Material Components, and how to migrate an old project off android.support.
Where Swift is heading: concurrency, server-side Swift and new platformsWhere Swift is heading beyond iOS: compile-time data-race safety, server-side frameworks, Linux, Windows, Android and WebAssembly SDKs, and what happened to Swift for TensorFlow.
Contributing to an open-source Swift package: fork, test and open a pull requestFind a Swift package to work on, fork and clone it, build and test with SwiftPM or Xcode, and open a pull request that maintainers can review quickly.
Jetpack Navigation for fragments: nav graphs, Safe Args, and deep linksSet up the Jetpack Navigation component in a fragment-based Android app: a navigation graph, a NavHostFragment, type-safe arguments with Safe Args, and deep links.
Unit testing in Swift with XCTest and Swift TestingSet up a test target in Xcode, write unit tests with XCTest assertions, run them, and see the same tests written with the newer Swift Testing framework.
Building a first iOS app in Xcode with Swift and storyboardsCreate an iOS app project in Xcode, find your way around the workspace, connect a storyboard button and label to Swift code, then run and debug it.
Swift error handling: throws, do-catch, try?, typed throws and rethrowsHow Swift error handling works: defining Error types, throwing and propagating errors, do-catch with patterns, try? and try!, typed throws, rethrows and defer.
Loading images on Android with Glide: setup, placeholders, transformations and cachingHow to add Glide to an Android project, load images into an ImageView with placeholders, apply built-in and custom transformations, and control caching.
Swift performance tips: build settings, dispatch, copy-on-write and inliningSwift performance tips that hold up: build with -O and whole-module optimization, cut dynamic dispatch, use copy-on-write and inout well, and measure first.
Scraping Steam's top sellers with Dart and beautiful_soup_dartFetch Steam's top sellers search page with the http package, parse it with beautiful_soup_dart, and serve the results from an Alfred endpoint.
The Android framework APIs: core packages and app componentsA map of the Android framework's core android.* packages and the four app components (activities, services, content providers, broadcast receivers), with current caveats.
Functional programming in Swift with closures, map/filter/reduce, and value typesFunctional programming in Swift with closures, map/filter/reduce, function types, value-type immutability, pattern matching, and recursion, with runnable examples.
Wrapping the Open Food Facts API with an Alfred server in DartA small Dart backend built with Alfred that turns query-string parameters into an Open Food Facts product search and returns the results as JSON.
Swift generics: generic functions, generic types and constraintsHow to write generic functions and types in Swift, constrain them with protocols and where clauses, and what generics cost at runtime.
Swift extensions: adding methods, properties and protocol conformances to existing typesHow Swift extensions add methods, computed properties, initializers and protocol conformances to existing types, plus what they can't do.
How I deployed a Dart Alfred server to a Hugging Face Docker SpaceCompiling a Dart Alfred HTTP server to a native executable and running it on a Hugging Face Docker Space with a multi-stage Dockerfile.
Picasso on Android: loading, resizing, and transforming imagesLoad images into Android ImageViews with Square's Picasso: placeholders, resizing, and custom transformations, plus the Coil equivalent now that Picasso is deprecated.
OkHttp on Android: making requests and adding interceptorsAdd OkHttp 5 to an Android app, make an asynchronous GET request without leaking responses, and write an interceptor for logging or auth headers.
Swift Package Manager basics: creating a package and managing dependenciesCreate a Swift package from the command line, add a dependency such as Alamofire to Package.swift, and update, pin or remove dependencies with SwiftPM.
Android Architecture Components: ViewModel, LiveData, Room, WorkManager and Navigation in KotlinA short Kotlin example for each of the main Jetpack architecture libraries (ViewModel, LiveData, Room, Data Binding, WorkManager, Navigation) and the gotchas in each.
Material Components for Android: themes and common widgets in XML layoutsSet up Material Components for Android (Views) with a Material 3 theme, then use buttons, text fields, cards, app bars, navigation views, and snackbars.
Debugging Swift in Xcode: breakpoints, LLDB, logging and sanitizersHow to debug Swift code in Xcode with breakpoints, LLDB's p, po and v commands, print and Logger output, and the Address and Thread Sanitizers.
Swift basics: variables, types, control flow and functionsSwift basics for newcomers: let and var, type inference, the core value types, optionals, if, switch, loops and functions with argument labels.
Building a Flutter Pokédex, part II: the Pokémon details screenThe details screen of my Flutter Pokédex: loading a Pokémon from bundled JSON and PokeAPI, then showing its description, abilities, size and a base-stat chart.
Generating a PDF resume in Dart with the pdf packageBuild a one-page resume PDF from Dart code with the pdf package, covering a centred header, two-column job and education rows, bullet points and skill tags.
Swift operators: arithmetic, bitwise, ranges and custom operatorsSwift's arithmetic, comparison, logical, bitwise, range and assignment operators, the overflow and nil-coalescing operators, and how to define a custom operator.
Building a Flutter Pokédex, part I: Figma, DhiWise and an infinite-scroll gridStarting a Flutter Pokédex from a Figma design and DhiWise-generated code, then building a lazily loading Pokémon grid and type-coloured cards.
Swift optionals: if let, guard let, optional chaining and ??How Swift optionals represent missing values, and how to unwrap them safely with if let, guard let, optional chaining, the ?? operator and map.
Swift protocols: requirements, extensions, associated types and compositionHow to define and adopt Swift protocols, add default implementations with extensions, use associated types, inheritance and composition, and choose between some and any.
Scraping Pokémon data and images for a Pokédex with PythonA Python script that pulls every Pokémon's name, ID and types from PokeAPI's GraphQL API, then finds an image for each one through Bulbapedia's MediaWiki API.
Parsing JSON with Klaxon in Kotlin: data classes, arrays and the json DSLUse the Klaxon library to parse JSON into Kotlin data classes, parse JSON arrays into lists, and build JSON with Klaxon's json DSL.
RxKotlin basics: creating, transforming and combining ObservablesSet up RxKotlin 3 with RxJava 3, create Observables, use map, filter, merge and zip, handle errors, and move work between threads with schedulers.
KAndroid Kotlin extensions for Android, and what replaces them todayWhat the KAndroid library offers (text watchers, toasts, intents, threading and logging helpers), how to add it with JitPack, and the AndroidX equivalents.
Anko for Android: Kotlin layout DSL, intents and dialogs (deprecated)How JetBrains' Anko built Android layouts, intents and dialogs in Kotlin code, why it's deprecated, and the Jetpack Compose equivalent.
Getting started with Flutter: create and run your first appWhat Flutter is, how its widget model works, and how to create, run and edit a first Flutter app with hot reload.
Side hustle income tracker in Flutter: SQLite storage and CSV exportA small Flutter app that records side hustle income in SQLite with sqflite, lists and deletes entries, and exports everything to a CSV file.
Writing a linear congruential generator (and a Rational class) in DartA linear congruential generator and a simplified-fraction Rational class in Dart 3, ported from my dart-basic-math-lib, with the gotchas around overflow and seeding.
Flutter todo list with SupabaseA small Flutter todo app backed by a Supabase table, covering listing, adding, completing and deleting todos with the supabase Dart client.
Intermittent build failures on react native android due to jcenterHow I migrate from jcenter to mavenCentral using patch files.
Basic React Native Templatereact native template for a basic app
Trump Quotes app for flutterRecently i was updating my flutter quotes trump app to use the latest version of flutter, here are some of the lessons i learned.
Flutter Remove background from image web app Part IIIAutomatical update app using fastlane
Flutter Remove background from image web app Part IIWIP web app that allows the user to download an image after the remove.bg api has been applied.
Flutter Remove background from image web app Part IWeb app / mobile app that allows the user to download an image after the remove.bg api has been applied.
© 2026 David Li · Home · Blog · RSS ·Classic site · Built with Astro, Starlight and three.js · Logos:Font Awesome Free (CC BY 4.0)