# Android APK build — Capacitor wrapper

This document describes how to produce a downloadable Android `.apk` for
AdultWorld using Capacitor as a thin wrapper around the live Next.js site.
The APK is intended to be hosted at `/downloads/adultworld.apk` and offered
to users on Android browsers as an alternative to the PWA install path
(adult content cannot ship in the Play Store).

## One-time setup

```bash
# From the repo root
npm install --save @capacitor/core @capacitor/cli @capacitor/android
npx cap init AdultWorld ai.adultworld.app --web-dir=public
npx cap add android
```

`capacitor.config.ts` should look approximately like:

```ts
import type { CapacitorConfig } from '@capacitor/cli';

const config: CapacitorConfig = {
  appId: 'ai.adultworld.app',
  appName: 'AdultWorld',
  webDir: 'public',
  server: {
    // The APK is a thin shell — actual content is loaded from the live
    // site so updates ship instantly without a rebuild.
    url: 'https://www.adultworld.ai',
    cleartext: false,
  },
};

export default config;
```

## Building the APK

```bash
# Sync the latest config + plugins into the android/ project
npx cap sync android

# Open Android Studio — easiest path; Android Studio will sign + assemble
# a release APK from android/app/build/outputs/apk/release/.
npx cap open android

# Or via Gradle directly:
cd android
./gradlew assembleRelease
```

Output: `android/app/build/outputs/apk/release/app-release.apk`.

## Signing

A debug-signed APK works for sideload but Android shows a scary warning.
For a production release:

1. Generate a keystore once: `keytool -genkey -v -keystore adultworld.keystore -alias adultworld -keyalg RSA -keysize 2048 -validity 10000`
2. Configure `android/app/build.gradle` `signingConfigs.release` with the
   keystore path + password + alias (use environment variables, not
   committed plaintext).
3. Re-run `assembleRelease`.

## Hosting

Drop the signed APK at `public/downloads/adultworld.apk`. Add a button on
the homepage (Android user-agent only) that links to `/downloads/adultworld.apk`
with `download="adultworld.apk"`.

## Maintenance

Because the APK loads `https://www.adultworld.ai` directly, content
changes ship without rebuilding. Only re-build when:

- Capacitor is upgraded
- A new native plugin is added (e.g. push notifications, file system)
- The signing keystore rotates
