# Build ## Prerequisites - Flutter 3.29+ (Dart 3.4+) - Android SDK Platform 35 - Android Build Tools 35.0.0 - JDK 17 or 21 - Windows: `JAVA_HOME` set to the JDK ## SDK setup (Windows, no Android Studio) ```powershell # 1. Flutter Expand-Archive C:\src\flutter.zip C:\src $env:Path = "C:\src\flutter\bin;$env:Path" flutter --version # 2. Android command-line tools Expand-Archive C:\Android\cmdline-tools.zip C:\Android\cmdline-tools # move so sdkmanager is at C:\Android\cmdline-tools\latest\bin $env:ANDROID_HOME = "C:\Android\Sdk" $env:Path = "C:\Android\cmdline-tools\latest\bin;$env:Path" sdkmanager --sdk_root=$env:ANDROID_HOME "platform-tools" "platforms;android-35" "build-tools;35.0.0" sdkmanager --sdk_root=$env:ANDROID_HOME --licenses flutter config --android-sdk $env:ANDROID_HOME flutter doctor ``` ## Project config Create `mobile-app/android/local.properties`: ```properties sdk.dir=C:\\Android\\Sdk flutter.sdk=C:\\src\\flutter ``` ## Build APK ```powershell cd mobile-app flutter pub get flutter build apk --release ``` Output: ```text mobile-app/build/app/outputs/flutter-apk/app-release.apk ``` ## Signing The scaffold uses the debug signing config for `release` so it can be installed for testing. Create a real keystore before distribution: ```powershell keytool -genkeypair -v -keystore ld-fdpi-mobile.jks -keyalg RSA -keysize 2048 -validity 10000 -alias ld-fdpi ``` Then replace `signingConfig = signingConfigs.debug` in `android/app/build.gradle` with a `signingConfigs.release` block and store credentials outside the repository. ## Install ```powershell adb install -r mobile-app\build\app\outputs\flutter-apk\app-release.apk ``` ## Important limitation The generated APK **will not establish a tunnel** until `android/app/src/main/jniLibs//libawg.so` exists. See `docs/TUNNEL_BACKEND.md`. The app intentionally refuses to connect instead of shipping a fake WireGuard fallback that the AmneziaWG server would reject. ## Tests before distribution 1. Clean install on Android 10 and Android 14. 2. Activation code → enrollment succeeds. 3. Connect → TUN + handshake. 4. Kill the native process/service → traffic must not leak. 5. Enable Always-on + Block without VPN in Android settings; reboot. 6. Disconnect → internet returns; DNS/egress IP test.