Application platform and composition
Metrolist is an Android music app assembled from one installable application module and one reusable InnerTube library module. The application owns startup, user-facing entry points, shared services, and dependency wiring. The library supplies the remote music client boundary without defining app screens or Android entry points.
Module boundaries
The app module is the product boundary. It creates the Android package, owns the application ID and version, declares the app manifest, and depends on :innertube for remote music access. The innertube module is an Android library with its own namespace and a minimal manifest, so it can provide client code without becoming a second application. (settings.gradle.kts• L39-42, app/build.gradle.kts• L35-65, app/build.gradle.kts• L302, innertube/build.gradle.kts• L1-12, innertube/…/AndroidManifest.xml• L1-3)
The dependency boundary keeps product concerns in the application while allowing the remote client to be selected from a published dependency or a local Maven build. Gradle resolves the InnerTube source through the repository rules in settings.gradle.kts, and the library exposes that client to the app through its API dependency. (settings.gradle.kts• L3-35, innertube/build.gradle.kts• L25-36)
| Boundary | Responsibility | Downstream effect |
|---|---|---|
app | Android product, shared resources, screens, services, receivers, and app-wide dependencies | Produces the installable Metrolist package |
innertube | Remote YouTube Music client support and response access | Gives the app a stable library boundary for catalog access |
| InnerTube dependency | Client implementation selected by repository configuration | Can change between a published artifact and a local build |
Dependency composition
Dependency composition gives application-wide resources one owner and one lifetime. Hilt creates the application graph from modules installed in SingletonComponent, while App supplies the Android application root that starts that graph. (App.kt• L41-64, di/AppModule.kt• L32-41)
The graph groups shared resources by role rather than by screen. Persistent data access, media caches, the network observer, and Listen Together services are available to app components through the application scope. Qualifiers keep the two media caches distinct because playback and downloads have different storage purposes. (di/AppModule.kt• L43-109, di/NetworkModule.kt• L17-25, di/Qualifiers.kt• L10-20)
This composition lets the activity and background components use the same database, cache, and coordination services. It also keeps construction policy outside those consumers, so a change to a shared resource can be made at the graph boundary instead of in each entry point. (MainActivity.kt• L252-262, di/AppModule.kt• L43-109)
Android startup
Android starts the declared Application before it starts the main activity. App performs process-wide setup in the main process, then MainActivity prepares the user session, binds to playback, and enters the Compose UI. Detailed activity and service lifecycle wiring is covered in Application lifecycle and integration points. (AndroidManifest.xml• L30-44, App.kt• L61-117, MainActivity.kt• L314-481)
The startup path loads saved settings before it configures remote access. It then starts background observers and warms remote playback state without blocking the first UI frame. The activity separately starts or binds to the playback service and handles intents that arrive at launch or while the activity already exists. (App.kt• L99-117, MainActivity.kt• L323-350, MainActivity.kt• L382-400, MainActivity.kt• L988-1010)
This diagram shows the high-level startup relationship between Android, the process root, the main activity, and long-lived services.
flowchart TD
A[Android package launch] --> B[App application root]
B --> C[Process-wide setup]
C --> D[Settings and remote client state]
A --> E[MainActivity]
E --> F[Compose navigation and UI]
E --> G[MusicService start and bind]
G --> H[Playback and media session]
E --> I[Intent and deep-link routing]
Manifest integration
The application manifest is the Android contract for the product. It names the application class and main activity, exposes supported launch and deep-link actions, and registers services and receivers that let playback, downloads, alarms, widgets, recognition, and external links work outside the visible screen. (app/…/AndroidManifest.xml• L30-71, app/…/AndroidManifest.xml• L79-159, app/…/AndroidManifest.xml• L233-285, app/…/AndroidManifest.xml• L290-376)
Manifest entries connect external Android events to app-owned behavior. The main activity accepts normal launches, shared text, YouTube links, media search, widget targets, and Listen Together links. Media and recognition services provide the long-lived capabilities that cannot depend on the activity remaining visible. (app/…/AndroidManifest.xml• L56-159, app/…/AndroidManifest.xml• L233-253, app/…/AndroidManifest.xml• L361-376)
The manifest also preserves user access across upgrades. The enabled launcher alias keeps older pinned icons valid, while the disabled alias provides an alternate launcher target that the app can select without changing the main activity. (app/…/AndroidManifest.xml• L161-191)
Variant composition
The application has FOSS, GMS, and Izzy product variants. They share the same application platform but change optional capabilities such as updating and Google Cast support. The variant choice therefore changes both the dependency set and the behavior exposed by BuildConfig. See Android build variants and distribution for signing, overrides, and release automation. (app/build.gradle.kts• L67-90, app/build.gradle.kts• L289-292, MainActivity.kt• L497-567)
The platform also supports controlled build-time overrides for identity and release metadata. These overrides let distribution systems use a different application ID or name without changing the app's source-level startup contract. (app/build.gradle.kts• L10-24, app/build.gradle.kts• L39-49)
Change checklist
When these files or sections are changed, remember to consider these:
- Changes to app/…/AndroidManifest.xml must remain aligned with the activity, service, receiver, and deep-link handlers that consume those Android events.
- Changes to app/build.gradle.kts that add or remove flavor-only dependencies must also preserve the matching
BuildConfigcapability flags and the UI or service guards that read them. - Changes to settings.gradle.kts or innertube/build.gradle.kts must preserve the
:appto:innertubeAPI boundary and both published and local InnerTube resolution paths. - Changes to di/AppModule.kt must preserve the cache qualifiers and the application-wide lifetimes expected by playback, downloads, and shared coordination services.
- Changes to App.kt must keep settings ready before remote access and must avoid full application setup in the crash process.
Important failure modes
| Trigger | Consequence | Guard |
|---|---|---|
| A manifest intent filter no longer matches its handler | Links, shares, widgets, or media controls open nothing or route to the wrong entry point | Keep manifest actions and data rules aligned with MainActivity intent handling |
| The crash process runs full application startup | WebView-backed work can claim the wrong data directory and affect the main process | App exits startup when the current process is not the package process |
| A flavor loses a matching optional dependency or capability flag | A build can reference an unavailable service or silently hide a supported feature | Keep flavor dependencies and BuildConfig guards in step |
| Player and download caches use the same graph binding | Playback data and downloads can evict or overwrite the wrong stored media | Keep PlayerCache and DownloadCache as separate qualified resources |
| The InnerTube module resolves from an unintended repository | The app can build against a different client source than the developer or release expects | Keep exclusive repository filters and the useMavenLocalInnerTubeX switch aligned |
Key files
| File | Why to read it |
|---|---|
| settings.gradle.kts | Defines the two-module product shape and InnerTube repository boundary. |
| app/build.gradle.kts | Defines the installable app, shared dependencies, flavors, and capability flags. |
| innertube/build.gradle.kts | Defines the reusable Android library and its client dependency boundary. |
| app/…/App.kt | Shows process-safe application startup and early shared-state setup. |
| app/…/MainActivity.kt | Shows the main activity entry point, playback connection, intent routing, and UI handoff. |
| app/…/AndroidManifest.xml | Defines Android-visible entry points for the app and its background capabilities. |
| app/…/AppModule.kt | Shows the main application dependency graph and shared resource lifetimes. |
| app/…/NetworkModule.kt | Shows the application-wide network observer binding. |