Nyx Mobile Infrastructure v2.0

Building Production Android Apps (.APK & .AAB) in Nyx

Complete engineering guide to authoring zero-GC mobile logic in Nyx, testing in the live phone simulator, and compiling directly into native Android APKs and Google Play AAB bundles via CLI and the Nyx App Studio IDE.

High-Level Architecture

Nyx mobile applications combine high-performance, deterministic core engines compiled with nyx.exe with an automated headless Android Shell pipeline. This delivers native hardware capabilities (BiometricPrompt, hardware Keystores, camera/file choosers, haptics) while preserving 0.00ms GC pause jitter.

1. Authoring Native App Logic in Nyx (.nyx)

Every mobile application starts with a clean, strongly-typed Nyx source file located under nyxmobile/apps/<category>/. Here is a production financial ledger and budget planner:

nyxmobile/apps/budget/sovereign_budget.nyxNyx v0.50.0
module nyxmobile.apps.budget.sovereign_budget;

pub struct Transaction {
    pub title: String,
    pub category: String,
    pub amount: f64,
    pub vat_amount: f64,
    pub is_income: bool
}

pub struct BudgetLedger {
    pub monthly_income: f64,
    pub monthly_expenses: f64,
    pub total_tax_withheld: f64,
    pub is_biometric_locked: bool
}

impl BudgetLedger {
    pub fn new() -> BudgetLedger {
        BudgetLedger {
            monthly_income: 0.0,
            monthly_expenses: 0.0,
            total_tax_withheld: 0.0,
            is_biometric_locked: true
        }
    }

    pub fn record_expense(self: &mut BudgetLedger, title: String, category: String, amount: f64) -> Transaction {
        let vat: f64 = amount * 0.075; // 7.5% Statutory VAT
        self.monthly_expenses = self.monthly_expenses + amount + vat;
        self.total_tax_withheld = self.total_tax_withheld + vat;
        return Transaction {
            title: title,
            category: category,
            amount: amount,
            vat_amount: vat,
            is_income: false
        };
    }
}

pub fn main() -> i64 {
    let mut ledger: BudgetLedger = BudgetLedger::new();
    let tx = ledger.record_expense("Server Colocation", "Infrastructure", 350000.0);
    println("[Ledger] Recorded: " + tx.title + " (VAT: NGN 26,250.00)");
    return 0;
}

Compile and verify your native application logic locally with nyx.exe:

.\nyx.exe -i nyxmobile\apps\budget\sovereign_budget.nyx -o nyxmobile\apps\budget\sovereign_budget.exe -r

2. Building the Mobile Web Interface

For cross-platform fluid UI, create a responsive mobile viewport in apps/<app_name>/index.html. Nyx mobile apps natively integrate with the Android hardware bridge through window.NyxNative:

apps/nyx_vault_budget/index.html (Hardware Bridge Integration)JavaScript
// Trigger Android Hardware Biometric Authentication
function authenticateUser() {
    if (window.NyxNative && window.NyxNative.showBiometricPrompt) {
        window.NyxNative.showBiometricPrompt("Authenticate Vault", "Scan fingerprint to unlock");
    } else {
        console.log("Running in browser fallback mode.");
    }
}

// Trigger Android Hardware Haptic Vibration
function onButtonPress() {
    if (window.NyxNative && window.NyxNative.vibrate) {
        window.NyxNative.vibrate(35); // 35ms haptic pulse
    }
}

3. Method A: The Nyx App Studio (Visual IDE)

Nyx includes a full-featured web-based visual mobile IDE at /nyx/studio/index.html. It allows anyone to design, live-test, and package apps without opening Android Studio:

1. Template Catalog

Choose from pre-built archetypes: Nyx Vault, Nyx Brain, Sovereign Messenger, Ninja Jumper 2D, Word Connect, or any custom URL.

2. Live Phone Simulator

Interactive Google Pixel 8 Pro / Galaxy S24 phone simulator with realistic notch, dynamic safe areas, and instant frame reloads.

3. Hardware Toggles

Easily enable Android BiometricPrompt, offline connection banners, and the window.NyxNative bridge with one switch.

4. 1-Click Build Dispatch

Click Build Android APK or Build Google Play AAB to trigger automated headless Gradle packaging.

4. Method B: Automated Headless CLI Pipeline

For CI/CD scripts and automated workflows, use the Nyx Mobile Wrap pipeline directly:

# Generate & compile NyxVault into APK and AAB
python scripts/nyx_mobile_wrap.py \
  --url "http://localhost/nyx/apps/nyx_vault_budget/index.html" \
  --name "NyxVault" \
  --package "com.nyx.vault" \
  --theme "#10B981" \
  --biometrics

# Generate & compile NyxBrain Challenge into APK and AAB
python scripts/nyx_mobile_wrap.py \
  --url "http://localhost/nyx/apps/nyx_brain_challenge/index.html" \
  --name "NyxBrain" \
  --package "com.nyx.brain" \
  --theme "#38BDF8"

Build Flags Reference:

5. Output Binaries & Distribution

When the headless Gradle build finishes, your binaries are placed in projects/mobile_<AppName>/bin/:

1. Android APK (.apk)

Use Case: Direct sideloading, enterprise internal distribution, and instant testing on any Android device or emulator.

Install via ADB:

adb install -r projects/mobile_NyxVault/bin/NyxVault.apk

2. Google Play Android App Bundle (.aab)

Use Case: Production release on Google Play Console.

The .aab package is optimized with dynamic feature delivery, allowing Google Play to serve device-specific splits (density, CPU ABI) reducing download sizes to under 4MB.

6. Native Hardware Features Reference

BiometricPrompt Gateway

Authenticates users via biometric sensors (fingerprint, face unlock) with automatic PIN/pattern fallback. Blocks screenshots when enabled.

Swipe-to-Refresh

Integrated Android SwipeRefreshLayout allowing intuitive pull-down page refresh matching native apps.

File & Camera Chooser

Custom WebChromeClient supporting HTML5 <input type="file"> with direct Android camera and file gallery capture.

Offline Reconnect Banner

Monitors network connectivity with Android ConnectivityManager; shows clean Material Snackbar when offline and auto-reconnects when network returns.