# 📱 Android APK Packaging Guide
## Presidential Situation Room & Collation System (Atiku 2027)
**Powered by GetoCore Digital Innovation**

This guide provides the complete, step-by-step procedure to package the Next.js web application into an installable Android Application Package (`.apk`) for field agents and supervisors.

---

## Method 1: Google Bubblewrap (Fastest & Easiest Way to Build .APK)

Google's **Bubblewrap CLI** converts your PWA (`manifest.json` + website URL) directly into a signed Android APK without needing Android Studio or complex native code.

### Step 1: Install Prerequisites (Node.js & Java JDK)
Make sure Java 17 or 21 (OpenJDK) and Node.js are installed on your machine:
```bash
# Verify Java version
java -version

# Install Bubblewrap CLI globally
npm install -g @bubblewrap/cli
```

### Step 2: Initialize the Android Project from your URL
```bash
# Run Bubblewrap wizard pointing to your deployed domain (or local network IP)
bubblewrap init --manifest="http://your-server-ip:3002/manifest.json"
```
The wizard will ask:
- **Application Name**: `Presidential Situation Room 2027`
- **Short Name**: `Atiku2027`
- **Application ID**: `ng.getocore.atiku2027.situationroom`
- **Signing Key**: It will automatically offer to generate a secure signing keystore for you.

### Step 3: Build the APK
```bash
bubblewrap build
```
Once the build completes, your APK file will be ready in the root folder:
📁 **`app-release-signed.apk`**

You can send this `.apk` file directly via WhatsApp, Telegram, or email to all field agents to install on their Android phones!

---

---

## Method 2: Capacitor Native Android Project (Fully Initialized in Workspace)

The native Android project is now **fully initialized, configured, and synchronized** in the repository at [`android/`](file:///Users/user/Desktop/atiku2027-situation-room/android).

### ✅ What Has Been Configured:
1. **Package ID**: `ng.getocore.atiku2027.situationroom`
2. **App Name**: `Presidential Situation Room 2027`
3. **Official App Icons**: Customized high-resolution Atiku Abubakar campaign seal icons configured across all mipmap densities (`hdpi`, `mdpi`, `xhdpi`, `xxhdpi`, `xxxhdpi`).
4. **Hardware Permissions**: Configured in `AndroidManifest.xml`:
   - `android.permission.CAMERA` (for Form EC8A live photo capture)
   - `android.permission.ACCESS_FINE_LOCATION` & `ACCESS_COARSE_LOCATION` (for Polling Unit GPS geotagging)
   - `android.permission.INTERNET` & `ACCESS_NETWORK_STATE` (for telemetry and cloud sync)
   - `android:usesCleartextTraffic="true"` (for seamless local Wi-Fi / Hotspot presentation testing)
5. **Cryptographic Signing Keystore**:
   - Keystore: `android/app/signing.keystore`
   - Alias: `atiku2027`
   - Store & Key Password: `nWHJcS7ayg5w`
   - Signer: Atiku Abubakar Campaign Council / GetoCore Digital Innovation
   - Automatically wired into `signingConfigs.release` in `android/app/build.gradle`.

### Ready-to-Distribute Binaries (Pre-Compiled & Signed):
- **Standalone Android APK** (for direct phone install & WhatsApp distribution):  
  📁 [`public/downloads/Atiku2027_Situation_Room.apk`](file:///Users/user/Desktop/atiku2027-situation-room/public/downloads/Atiku2027_Situation_Room.apk)  
  📁 [`android/app/build/outputs/apk/release/app-release-signed.apk`](file:///Users/user/Desktop/atiku2027-situation-room/android/app/build/outputs/apk/release/app-release-signed.apk)
- **Google Play Store App Bundle** (`.aab` for Google Play Console):  
  📁 [`public/downloads/Atiku2027_Situation_Room.aab`](file:///Users/user/Desktop/atiku2027-situation-room/public/downloads/Atiku2027_Situation_Room.aab)  
  📁 [`android/app/build/outputs/app-release.aab`](file:///Users/user/Desktop/atiku2027-situation-room/android/app/build/outputs/app-release.aab)

### Re-Building or Updating the Project:
To sync any web changes to the Android project:
```bash
# 1. Build the web app
npm run build

# 2. Sync to Android project
npx cap sync android

# 3. Open in Android Studio (if installed)
npx cap open android

# 4. Or compile via Gradle (requires JDK 17+ & Android SDK)
cd android
./gradlew assembleRelease
```

---

## Method 3: Direct Download via Situation Room Mobile App Center

Field agents and supervisors can download the APK directly from the running web terminal:
1. Open the situation room on any mobile phone or browser:
   `http://your-server-ip:3002`
2. Tap the **"Mobile App"** button (or open the **Accreditation / Mobile App Center** modal).
3. Under the **"Android APK"** tab:
   - Tap **"Download APK (.apk) — Direct Install"** to save `Atiku2027_Situation_Room.apk` directly to the phone.
   - Or tap **"Google Play (.aab)"** to download the Play Store release bundle.
4. On the Android handset:
   - Tap the downloaded file.
   - If prompted *"For your security, your phone is not allowed to install unknown apps from this source"*, tap **Settings** &rarr; **Allow from this source**.
   - Tap **Install**.

---

## Method 4: Zero-Install PWA (Immediate Direct-to-Phone Alternative)

Before you distribute an APK, field agents can use the app immediately with **no APK download required**:
1. Open the situation room link in **Google Chrome** on any Android phone:
   `http://your-server-ip:3002/login`
2. Chrome will detect `public/manifest.json` and automatically show a prompt:
   **"Add to Home Screen"** or **"Install App"**.
3. Tap **Install**.
4. The official **Atiku Abubakar campaign seal icon** is immediately added to the agent's Android home screen and app drawer.
5. When tapped, it opens in **full-screen standalone app mode** (no browser address bar, with offline storage and camera access).

---

## Technical Support & Key Recovery
- **Signing Keystore**: `android/app/signing.keystore`
- **Signing Key Info**: `android/app/signing-key-info.txt`
- **GetoCore Technical Support Desk**: Electoral Technology Directorate
