Passer au contenu

Android Builds

Construction and Soumettre Android apps to the Google Play Store using Capgo’s secure cloud infrastructure.

Android builds run in secure Cloudflare sandboxes:

  • Infrastructure: Cloudflare Workers with containerized Android SDK
  • Construction Tool: Gradle with Android Construction tools
  • Execution: Isolated sandbox environment per Construction
  • Cleanup: Instant deletion after Construction completion
  • Sécurité: No persistent storage, Terminé isolation between builds

Before Construction for Android, you need:

1. Développement Environment (Local Test)

Section titled “1. Développement Environment (Local Test)”
  • Android Studio installed locally (for initial keystore Configuration)
  • Your app building successfully with npx cap open android
  • Java JDK 17 or higher

For Libération builds, you need a signing keystore:

Construction TypeKeystore RequiredPurpose
DébogageNoTest only, auto-generated
LibérationYesPlay Store submission

If you don’t have a keystore yet, Créer one:

Terminal window
keytool -genkey -v \
-keystore my-release-key.keystore \
-alias my-key-alias \
-keyalg RSA \
-keysize 2048 \
-validity 10000

Answer the prompts:

  • Password: Choose a strong password (Enregistrer it securely!)
  • Name: Your name or company name
  • Organisation: Your company name
  • Location: Your city, state, country

When creating a keystore, you’ll need to remember:

  1. Keystore Password (KEYSTORE_STORE_PASSWORD): The password for the keystore file itself
  2. Key Alias (KEYSTORE_KEY_ALIAS): The name/identifier for your signing key within the keystore
  3. Key Password (KEYSTORE_KEY_PASSWORD): The password for the specific key (can be the same as store password)

Example workflow:

Terminal window
# List aliases in your keystore to verify
keytool -list -keystore my-release-key.keystore
# View detailed information about your key
keytool -list -v -keystore my-release-key.keystore -alias my-key-alias

For Libération builds, set these credentials:

Terminal window
# Android Signing (Required for release)
ANDROID_KEYSTORE_FILE="<base64-encoded-keystore>"
KEYSTORE_KEY_ALIAS="my-key-alias"
KEYSTORE_KEY_PASSWORD="<key-password>"
KEYSTORE_STORE_PASSWORD="<store-password>"
# Play Store Publishing (Optional, for auto-submission)
PLAY_CONFIG_JSON="<base64-encoded-service-account-json>"

Keystore File:

Terminal window
base64 -i my-release-key.keystore | pbcopy

Play Store Service Account JSON:

Terminal window
base64 -i play-store-service-account.json | pbcopy

The base64 string is now in your clipboard.

To Activer automatic Play Store uploads, you need to Créer a Google Cloud service Compte with proper permissions.

  1. Créer Service Compte in Google Cloud

    • Go to Google Play Console → Configuration → API Access
    • Click “Créer Nouveau service Compte”
    • Follow the link to Google Cloud Console
    • Click “Créer Service Compte”
    • Enter a name (e.g., “Capgo CI/CD”)
    • Grant the “Service Compte Utilisateur” role
    • Click “Done”
  2. Créer JSON Key

    • In Google Cloud Console, find your service Compte
    • Click on the service Compte email
    • Go to “Keys” tab
    • Click “Ajouter Key” → “Créer Nouveau key”
    • Choose “JSON” format
    • Télécharger the JSON file (keep it secure!)
  3. Grant Permissions in Play Console

    • Go Retour to Google Play Console → Configuration → API Access
    • Find your service Compte in the list
    • Click “Grant access”
    • Under “Application permissions”, select your Application
    • Under “Compte permissions”, grant:
      • Releases: “View Application Information and Télécharger bulk reports (read-only)”
      • Releases: “Créer, Modifier, and Supprimer draft releases”
      • Releases: “Libération to Production, exclude Appareils, and use Play Application Signing”
    • Click “Invite Utilisateur”
  4. Accept the Invitation

    • The service Compte will receive an invitation email
    • Accept the invitation to activate the permissions

Perfect for Test without signing:

Terminal window
npx @capgo/cli@latest build com.example.app \
--platform android \
--build-mode debug

This creates a Débogage APK that can be installed on any Appareil for Test.

For Play Store submission:

Terminal window
npx @capgo/cli@latest build com.example.app \
--platform android \
--build-mode release

Requires signing credentials to be configured as environment variables.

name: Build Android App
on:
push:
branches: [main]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Setup Node.js
uses: actions/setup-node@v6
with:
node-version: '24'
- name: Install dependencies
run: npm ci
- name: Build web assets
run: npm run build
- name: Sync Capacitor
run: npx cap sync android
- name: Build Android app
env:
CAPGO_TOKEN: ${{ secrets.CAPGO_TOKEN }}
ANDROID_KEYSTORE_FILE: ${{ secrets.ANDROID_KEYSTORE }}
KEYSTORE_KEY_ALIAS: ${{ secrets.KEYSTORE_ALIAS }}
KEYSTORE_KEY_PASSWORD: ${{ secrets.KEYSTORE_KEY_PASSWORD }}
KEYSTORE_STORE_PASSWORD: ${{ secrets.KEYSTORE_STORE_PASSWORD }}
PLAY_CONFIG_JSON: ${{ secrets.PLAY_STORE_CONFIG }}
run: |
npx @capgo/cli@latest build ${{ secrets.APP_ID }} \
--platform android \
--build-mode release

What Happens During an Android Construction

Section titled “What Happens During an Android Construction”
  1. Sandbox Initialisation (~5 seconds)

    • Secure container spun up
    • Android SDK and Gradle loaded
    • Isolated file system created
  2. Project Configuration (~20 seconds)

    • Project zip downloaded from R2
    • Extracted to Construction directory
    • Signing credentials injected
  3. Gradle Construction (2-4 minutes)

    • Dependencies downloaded
    • APK/AAB compilation
    • ProGuard/R8 optimization (Libération mode)
    • Code signing applied
  4. Play Store Télécharger (30 seconds, if configured)

    • AAB uploaded to Play Console
    • Libération track configured
    • Submission initiated
  5. Cleanup (immediate)

    • All files deleted
    • Container destroyed
    • No artifacts retained

Our Android Construction environment includes:

  • Java: OpenJDK 17
  • Android SDK: Latest Stable
  • Gradle: 8.x
  • Construction Tools: 34.x
  • Node.js: 18.x (LTS)
  • NPM: Latest Stable
  • APK (Android Package): Installable file for direct Installation
  • AAB (Android Application Bundle): Google Play’s recommended format (smaller downloads for Utilisateurs)

By default, Capgo builds Créer:

  • Débogage mode: APK
  • Libération mode: AAB (optimized for Play Store)

Typical Android Construction times:

Construction TypeAverage Time
Débogage2-3 minutes
Libération (no ProGuard)3-4 minutes
Libération (with ProGuard)4-6 minutes

If your app has custom build variants (e.g., staging, production), use build-config:

Terminal window
npx @capgo/cli@latest build com.example.app \
--platform android \
--build-mode release \
--build-config '{"variant":"staging"}'

This will build the stagingRelease variant.

For apps with flavor dimensions:

Terminal window
--build-config '{"flavor":"premium","variant":"production"}'

This builds the premiumProductionRelease variant.

“Keystore password incorrect”

  • Verify KEYSTORE_STORE_PASSWORD matches your keystore
  • Ensure KEYSTORE_KEY_PASSWORD matches your key alias password
  • Vérifier for extra spaces or special characters

“Key alias not found”

  • Verify KEYSTORE_KEY_ALIAS matches exactly (case-sensitive)
  • List aliases: keytool -list -keystore my-release-key.keystore

“Gradle build failed”

  • Vérifier Construction Journaux for the specific Erreur
  • Ensure your app builds locally with ./gradlew assembleRelease
  • Verify all native dependencies are in build.gradle

“Play Store upload failed”

  • Verify service Compte JSON is valid
  • Ensure service Compte has correct permissions in Play Console
  • Vérifier that Application is properly set up in Play Console

“Build timeout”

  • Large apps may need optimization
  • Vérifier if unnecessary dependencies can be removed
  • Contact Support if builds consistently timeout

Watch for these key phases in the Construction Journaux:

→ Downloading dependencies...
→ Running Gradle assembleRelease...
→ Signing APK/AAB...
→ Uploading to Play Store...
✔ Build succeeded

If a Construction fails, the specific Gradle Erreur will be shown in the Journaux.

Always ensure your Android Construction works locally:

Terminal window
cd android
./gradlew assembleRelease
# or
./gradlew bundleRelease
  • Never commit keystores to Version control
  • Store in secure secrets management (1Password, AWS Secrets Manager, etc.)
  • Keep backup copies in multiple secure locations
  • Document passwords in a secure password manager

Capgo reads version from your capacitor.config.json:

{
"appId": "com.example.app",
"appName": "My App",
"version": "1.0.0",
"build": "1"
}

Increment the build number for each release.

For Libération builds, ensure ProGuard rules are properly configured:

android/app/proguard-rules.pro
-keep class com.getcapacitor.** { *; }
-keep @com.getcapacitor.annotation.CapacitorPlugin public class * {
@com.getcapacitor.annotation.PluginMethod public <methods>;
}

Keep an eye on APK/AAB size to ensure it’s optimized:

The CLI shows final size:
→ APK size: 12.4 MB

If your Application is large (>50 MB), consider:

  • Enabling ProGuard/R8
  • Using AAB format (dynamic delivery)
  • Optimizing images and assets

With PLAY_CONFIG_JSON configured, builds are automatically uploaded to Play Console’s internal Test track.

If you prefer manual submission:

  1. Run the Construction without PLAY_CONFIG_JSON
  2. Télécharger the AAB from Construction artifacts (if configured)
  3. Télécharger manually to Play Console