# AURA LIVE — Android Build Guide (APK / AAB)

Build the genuine React Native app on your machine (Java 17 + Android SDK required).

## 1. Prerequisites
- **Node 18+**, **Java 17 (JDK)**, **Android Studio** (SDK 34 + platform-tools)
- Environment vars: `ANDROID_HOME=~/Android/Sdk`, `JAVA_HOME=<jdk17 path>`

## 2. Create the native project (one time)
This repo ships JS/TS source + config. Generate the native shell:

```bash
cd apps/mobile
npm install                       # installs JS deps
# Generate android/ folder using the RN template pinned to this version:
npx react-native@0.73.6 init AuraLive --version 0.73.6 --skip-install --directory /tmp/auralive-native
cp -r /tmp/auralive-native/android ./android
```
Then merge:
- `android/ANDROID_MANIFEST_SNIPPET.xml` permissions into `android/app/src/main/AndroidManifest.xml`
- `android/BUILD_GRADLE_SNIPPET.gradle` sections into `android/app/build.gradle`

## 3. Point the app to your backend
Edit `src/config/env.ts`:
- Emulator: `http://10.0.2.2:4000` (default, reaches your dev machine)
- Real device on same Wi-Fi: use your PC LAN IP e.g. `http://192.168.1.5:4000`
- Production: set the non-`__DEV__` URL to your HTTPS API domain.

## 4. Debug run
```bash
npm run android          # builds + installs debug APK + starts metro
```

## 5. Release APK / AAB
```bash
cd android
# create upload keystore (keep safe, never commit!)
keytool -genkeypair -v -storetype PKCS12 \
  -keystore app/aura-live-release.keystore -alias aura-live \
  -keyalg RSA -keysize 2048 -validity 10000

export AURA_KEYSTORE_PASSWORD=yourStrongPassword
export AURA_KEY_PASSWORD=yourStrongPassword
./gradlew assembleRelease          # → app/build/outputs/apk/release/app-release.apk
./gradlew bundleRelease            # → Play Store .aab
```

## 6. Push notifications (optional)
1. Create a Firebase project → add Android app `com.auralive` → download `google-services.json` into `android/app/`.
2. Uncomment FCM lines in `android/app/build.gradle` snippet.
3. Add `@react-native-firebase/messaging` when ready and forward tokens to `POST /users/me/device`.

## 7. Payments (Razorpay checkout)
Add `react-native-razorpay` and open checkout with the `checkout` payload returned by
`POST /payments/orders` (key_id + order_id). On success call `POST /payments/verify`
with `{ razorpay_order_id, razorpay_payment_id, razorpay_signature }`.
Coins are credited ONLY after server-side signature verification.

## 8. Permissions behaviour
- Microphone is requested ONLY when the user takes a mic seat.
- Denial is handled gracefully: the user can still listen, chat and send gifts.
