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.
- Open Android Studio
- Open Tools → Device Manager
- Click Create Device
- Select the Phone category and choose a recent Pixel model
- Select a recent Android OS version
- Click Finish to create the AVD
Configure the project for testing
Before you build, check the app’s configuration:
- Open
build.gradle(app level) - Verify all API endpoints point to staging or test environments
- Confirm API keys and configurations are for the test environment only
- Remove any production-specific security measures that would block testing
Open your project
- Launch Android Studio
- Open your Android app project
- Wait for Gradle sync to finish, and fix any sync errors before you go on.
Generate the APK
- Select Build → Build Bundle(s) / APK(s) → Build APK(s)
- Wait for the build to finish. The first build can take several minutes.
- 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.apkVerify your build
Before you upload, test the APK on your emulator:
- Start your Android Virtual Device from Device Manager
- Install the APK by dragging the APK file onto the emulator window
- Launch the app from the app drawer
- Verify the test environment: Confirm it connects to your staging or test servers
- 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.
- In Pie, open Builds and select Upload build.
- Choose the
app-debug.apkfile. - 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:
- Open the Build Variants panel, usually on the left side
- Select the variant you want, for example
stagingDebug - 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:
- Close all terminal windows running Metro
- Install and launch the APK on the emulator
- 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.gradlefor 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
*.apkfiles 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
INTERNETpermission inAndroidManifest.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.gradleconfiguration - 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.