📚 Encyclopedia

Android · updated 2026-11-02

Building an Android browser on GeckoView (Tokay)

geckoviewandroidkotlinjetpack-composebrowserwebextensionsublockkagigradledevtoolsautofilluserscripts

GeckoView is Mozilla's embeddable Firefox engine for Android: a library, not a fork, so an app gets Gecko rendering, WebExtensions and tracking protection without maintaining a browser. Justin's own browser Tokay (package io.jhampton.tokay, Kotlin + Jetpack Compose, about 3,200 lines, shipped 2026-10-13 through apps.jhampton.io and its F-Droid repo) is built on it. This article collects the toolchain facts and the GeckoView behaviors that cost time.

Toolchain (proven 2026-10)

GeckoView behaviors that bite

WebExtensions

Developer tools on a phone

Touch and pull to refresh

To decide whether a downward drag is a page scroll or a pull-to-refresh, feed ACTION_DOWN through GeckoView.onTouchEventForDetailResult and read the InputResultDetail: allow the pull only when the result is not HANDLED_CONTENT, the page is not scrollable upward (no SCROLLABLE_FLAG_TOP), and Gecko reports UNHANDLED or vertical overscroll. Pages with overscroll-behavior-y: none correctly report no overscroll and never pull. Once the drag passes touch slop downward, send Gecko an ACTION_CANCEL and take the gesture. Occasionally the detail for the first touch after a dialog never resolves; treat that as "no pull".

Tab thumbnails

GeckoView.capturePixels() captures only the session currently attached to the single engine view, asynchronously. Take it shortly after onPageStop for the current tab and when opening the tab switcher, and discard it if the view's session changed in between (a swap mixes pictures up). Scale to a small width, keep the top portion, store normal tabs as JPEG files and private tabs in memory only, and prune files for closed tabs at startup.

Saved passwords, cards and addresses

Importing from other browsers

Sync: the options and the recommendation

GeckoView has no built-in sync. Options weighed in 2026-10 (post #1779): - Own-server sync helps only someone with the same browser on two devices, and means holding other people's encrypted passwords on a small server with no backups. Not worth it. - Firefox Sync through Mozilla's android-components/application-services gives real two-way bookmarks, passwords, history and tabs with desktop Firefox, end-to-end encrypted. Costs: roughly 8 to 10 MB more per arm64 APK, Mozilla's telemetry library comes along (can be switched off), bookmarks/history move into Mozilla's Places storage (big rework), and Mozilla accounts only accept registered OAuth clients: small Firefox-based browsers (Iceraven, for example) sign in by reusing Firefox's client id, which works but is unofficial and blockable. - Chrome sync is closed to other browsers, so importers are the only help for Chrome users. Recommendation taken: skip sync; make first-day import easy instead (Chrome and Firefox files, and check that Android Autofill password managers fill in the browser).

Android integration

Desktop is a different project

GeckoView is Android only; there is no supported desktop Gecko embedding. Desktop paths are a customized official Firefox (policies.json, bundled extensions, Firefox's own UI), a full Firefox fork from mozilla-central (first Linux build about 45 to 90 minutes on a 16-thread machine, and the real cost is rebasing every 4-week release), or a different engine (Compose Desktop plus Chromium via JCEF).

Design choices worth copying

Gotchas

See also

Linked from

Sources: home memory project_tokay, misc-side-projects (Tokay), tokay memory (0.1.1 to 0.3.7), tldr posts #1768, #1779, #1781, #1782, #1783, #1795, #1809, #1813, #1827, tokay memory (0.3.8), tldr post #1851