# NexStream Release/Backup/R8 Session Notes — 2026-05-20

## Trigger

After Claude/Codex completed the main risky work and OpenCode GLM stalled on repo-editing tasks, the user asked to use Cursor for the remaining backlog but specifically required:

- search official docs / forums / GitHub first;
- choose the best approach from that research;
- enforce build/test after each implementation batch;
- keep the app at 0 build errors.

Cursor's Pro API-model pool was capped across GPT-5.5, Gemini, and Kimi, so the researched chunk was implemented directly.

## Research sources checked

- Android TV app quality guidelines: `https://developer.android.com/docs/quality-guidelines/tv-app-quality`
- Android TV app creation / Leanback launcher docs: `https://developer.android.com/training/tv/start/start`
- Android data backup overview: `https://developer.android.com/identity/data/backup`
- R8 keep-rules docs: `https://developer.android.com/topic/performance/app-optimization/add-keep-rules`
- Room migration docs: `https://developer.android.com/training/data-storage/room/migrating-db-versions`
- Media3 ExoPlayer troubleshooting: `https://developer.android.com/media/media3/exoplayer/troubleshooting`
- LeakCanary getting started: `https://square.github.io/leakcanary/getting_started/`
- GitHub/forum search highlights: AndroidX Media R8 issues, Leanback launcher manifest issues, Compose TV focus restoration discussions.

## Decisions

### Backup/export/import

Use an app-owned JSON backup foundation rather than Android Auto Backup because the manifest intentionally has `allowBackup=false` and token storage must remain excluded from backups.

Rules:

- export only non-secret settings/preferences first;
- include `schemaVersion`;
- never export debrid/Trakt tokens, cookies, API keys, diagnostics, or full tokenized URLs;
- avoid Room schema changes for the first foundation;
- add file picker/share-sheet later after repository surface is proven.

Implemented file:

- `app/src/main/java/com/nexstream/app/data/backup/BackupRepository.kt`

APIs:

- `exportNonSecretBackup(): String`
- `importNonSecretBackup(rawJson): BackupImportResult`

### LeakCanary

Use debug-only dependency only:

```kotlin
debugImplementation("com.squareup.leakcanary:leakcanary-android:2.14")
```

No release dependency and no Application wiring unless a future issue proves it is needed; LeakCanary auto-installs in normal Android apps.

### R8 / ProGuard

For this app, release verification is mandatory after ProGuard/R8 changes:

```bash
./gradlew assembleRelease
```

Actual release failure found:

```text
R8: Missing class coil3.PlatformContext
```

Fix added to `app/proguard-rules.pro`:

```proguard
-dontwarn coil3.PlatformContext
```

Release minification then passed.

## Verification chain

After the direct chunk:

```bash
./gradlew compileDebugKotlin testDebugUnitTest assembleDebug assembleRelease
```

Result: `BUILD SUCCESSFUL` with 0 build errors.

## Prompting pattern for future Cursor/agent handoff

For NexStream remaining-work chunks, use a narrow task prompt that says:

1. Read `docs/REMAINING_WORK_RESEARCH.md` and current handoff docs first.
2. Do not edit `.gradle/`, `build/`, generated sources, Room schema, or token storage unless explicitly required.
3. Do not export secrets or log tokenized URLs.
4. After each implementation batch run:
   - `./gradlew compileDebugKotlin`
   - `./gradlew testDebugUnitTest`
   - `./gradlew assembleDebug`
5. If release/R8 changed, also run:
   - `./gradlew assembleRelease`
6. Stop on first failure and write exact output to `docs/cursor_reports/<chunk>.md`.
7. End with files changed, commands run, pass/fail results, and remaining work.

## Remaining after this session

- Android document picker / share sheet for saving/restoring backup files.
- Expand backup to profile/watchlist/progress Room data after DAO review.
- Full Addon Control Center polish.
- Full Debrid setup UX redesign.
- Real-device Fire TV / Android TV QA.
