Android apps

Build an APK of your Android app, check it on an emulator and upload it to Pie. The steps are the same for native and React Native Android apps. Pie takes an .apk only: Android App Bundles (.aab) don’t work.

Before you start

  • Android Studio: A current version with the Android SDK
  • Android Virtual Device (AVD): A configured emulator
  • Your Android project: Native or React Native Android app
  • Java Development Kit (JDK): Set up, usually bundled with Android Studio

Point the build at a test or staging environment. See Prepare mobile builds for the requirements that apply to every platform.

Create an Android Virtual Device

Skip this step if you already have an AVD.

  1. Open Android Studio
  2. Open Tools → Device Manager
  3. Click Create Device
  4. Select the Phone category and choose a recent Pixel model
  5. Select a recent Android OS version
  6. Click Finish to create the AVD

Configure the project for testing

Before you build, check the app’s configuration:

  1. Open build.gradle (app level)
  2. Verify all API endpoints point to staging or test environments
  3. Confirm API keys and configurations are for the test environment only
  4. Remove any production-specific security measures that would block testing

Open your project

  1. Launch Android Studio
  2. Open your Android app project
  3. Wait for Gradle sync to finish, and fix any sync errors before you go on.

Generate the APK

  1. Select Build → Build Bundle(s) / APK(s) → Build APK(s)
  2. Wait for the build to finish. The first build can take several minutes.
  3. When it’s done, a notification links to the APK.

Locate your APK

  • Option A: Click locate in the build completion notification.
  • Option B: Go to the default path:
app/build/outputs/apk/debug/app-debug.apk
ℹ️
The path can differ with the build type (debug or release), product flavors and custom output directories.

Verify your build

Before you upload, test the APK on your emulator:

  1. Start your Android Virtual Device from Device Manager
  2. Install the APK by dragging the APK file onto the emulator window
  3. Launch the app from the app drawer
  4. Verify the test environment: Confirm it connects to your staging or test servers
  5. Test basic functionality: Go through the key features to check the app is stable

Upload to Pie

Upload the APK as it is. It doesn’t need zipping.

  1. In Pie, open Builds and select Upload build.
  2. Choose the app-debug.apk file.
  3. Enter a Build ID and select Submit for testing.

What you’ll see

Build uploaded means the file reached Pie, and the build appears in Builds. It doesn’t mean Pie accepted the build: if Pie refuses it, the portal shows nothing more. Choose your build under Select Build when you start a run. Then tell Pie how to sign in and what to test with the post-upload requirements.

Build configuration best practices

Use debug or staging variants

  • Debug builds work best for testing, because they include diagnostics.
  • Avoid release builds unless you need one, because they may be obfuscated.
  • If you use build flavors, use staging or QA flavors, not production.

Environment configuration

Check the build types in build.gradle:

android {
    buildTypes {
        debug {
            applicationIdSuffix ".debug"
            debuggable true
            // Test environment configuration
        }
    }
}

Permissions

Make sure AndroidManifest.xml has the permissions your app needs:

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<!-- Add other required permissions -->

Security features

In test builds:

  • Disable anti-debugging features that might interfere with testing
  • Remove certificate pinning for test environments
  • Disable ProGuard/R8 obfuscation in debug builds
  • Allow cleartext traffic for test endpoints, if needed

Example network security configuration for testing:

<!-- res/xml/network_security_config.xml -->
<network-security-config>
    <domain-config cleartextTrafficPermitted="true">
        <domain includeSubdomains="true">your-test-server.com</domain>
    </domain-config>
</network-security-config>

Build variants and flavors

If your project uses product flavors:

android {
    flavorDimensions "environment"
    productFlavors {
        staging {
            dimension "environment"
            applicationIdSuffix ".staging"
            // Use this variant for Pie testing
        }
        production {
            dimension "environment"
            // Don't use for testing
        }
    }
}

To build a specific flavor:

  1. Open the Build Variants panel, usually on the left side
  2. Select the variant you want, for example stagingDebug
  3. Build the APK with Build → Build Bundle(s) / APK(s) → Build APK(s)

API level compatibility

  • Minimum SDK: API 21 (Android 5.0) or higher recommended
  • Target SDK: A recent version
  • Test on: Recent Android versions in your AVD

React Native Android apps

For a React Native Android app, three things differ from a native build.

JavaScript bundle

React Native bundles the JavaScript into debug builds for you. Debug APKs need no extra bundling step.

Metro bundler

The APK is self-contained and doesn’t need Metro to run. To check:

  1. Close all terminal windows running Metro
  2. Install and launch the APK on the emulator
  3. Confirm the app runs without connecting to Metro

Assets

The build includes all JavaScript assets in the APK.

Troubleshooting

Gradle sync failed

Problem: The project won’t sync with Gradle.

Solutions:

  • Check your internet connection, because Gradle may need to download dependencies
  • Update Android Studio to the current version
  • Navigate to File → Invalidate Caches → Restart
  • Check build.gradle for syntax errors
  • Check the JDK path

Build failed with errors

Problem: The build process fails with compilation errors.

Solutions:

  • Read the error message in the Build Output panel
  • Check for missing dependencies in build.gradle
  • Verify all imported libraries are compatible with your target SDK
  • Clean and rebuild: Build → Clean Project, then Build → Rebuild Project

APK not found

Problem: You can’t find the APK.

Solutions:

  • Use the locate link in the build notification
  • Search for *.apk files in your project directory
  • Check whether you have custom output directories defined in build.gradle
  • Verify the build completed successfully in the Build Output panel

App crashes on launch

Problem: The APK installs but crashes immediately.

Solutions:

  • Check Logcat in Android Studio for crash logs
  • Verify all required permissions are in AndroidManifest.xml
  • Confirm the minimum SDK version is compatible
  • Check for missing native dependencies
  • Check your ProGuard rules if you use code obfuscation

Network connection issues

Problem: The app can’t connect to backend services.

Solutions:

  • Verify the INTERNET permission in AndroidManifest.xml
  • Check that API endpoints are accessible from external networks
  • Confirm the network security configuration allows connections to test servers
  • Test endpoint connectivity from a web browser

Wrong environment

Problem: The app connects to production instead of the test environment.

Solutions:

  • Double-check your build.gradle configuration
  • Verify the build variant is debug or staging, not release
  • Check for hardcoded production URLs in code
  • Confirm environment variables are set

Still stuck? Contact support@pie.inc with your Android Studio version, Gradle version, build errors or Logcat output, and a description of the issue.

Next steps

Last updated on