Build an APK from a GitHub repository
Do more with Build Android APK Integrations
Connect a GitHub repo and get a release APK built in the cloud on every push, with no Android Studio or local SDK.
Use Build Android APK with GitHub in Buddy CI/CDHow to build an APK from GitHub
The Build Android APK action compiles your GitHub repository in the cloud. It runs ./gradlew assembleRelease in an openJDK environment with the Android SDK and Build Tools versions you pick, so you don't need Android Studio or an SDK on your machine. The APK stays in the pipeline filesystem, where you can sign it, download it or send it to Google Play.
- Create a project in Buddy, choose GitHub as the Git provider and select the repository.
- Add a pipeline. Set the trigger to On push for
main, or run it manually. - Add Build Android APK. Pick the SDK version that matches
compileSdkinapp/build.gradle. Ifgradlewis not in the repository root,cdinto its folder first. - Run the pipeline. The output is
app/build/outputs/apk/release/app-release-unsigned.apk. - Add Sign APK with your release keystore, stored in Buddy instead of the repository. Then save the APK as an artifact or publish it to Google Play.
When this happens...
GitHub Push / Bitbucket Push / Git Push
Then do this...
Build Android APK
Sign APK
Check what's in the repository first
| In the repo | What it is | What to do |
|---|---|---|
build.gradle or build.gradle.kts, an app/ folder, gradlew | A native Android project | Follow the steps above. |
pubspec.yaml | A Flutter app | Use the Flutter build APK pipeline instead. |
package.json, index.html, src/ | A web app, for example an export from an AI app builder | Wrap it with Capacitor first. The ZIP to APK tutorial covers it step by step, and it works the same for a GitHub repo. |
Only a .apk file under Releases | An app that is already built | Nothing to build. Download the APK from the Releases page. |
How long it takes
We built android/architecture-samples (Jetpack Compose, Hilt, R8 minification) with the steps above, on a pipeline with resources: XLARGE (4 vCPU, 8 GB RAM). The first run took 2 min 31 s, including the Android SDK download. With /root/.gradle and the SDK folder cached, the next run took 1 min 10 s.
On the smallest machine (2 vCPU, 3 GB RAM) the same build failed because Gradle ran out of memory at the R8 step.
Common errors
- The APK won't install on the phone.
assembleReleaseproduces an unsigned APK, and Android refuses to install unsigned files. Add the Sign APK action. Permission denied: ./gradlew. The file lost its executable bit, which often happens with commits made on Windows. Rungit update-index --chmod=+x gradlew, commit and push.Failed to find target with hash string 'android-34'. The SDK version in the action doesn't matchcompileSdk. Change one of them so they match.Gradle build daemon disappeared unexpectedly. The build ran out of memory, for example atminifyReleaseWithR8. Raise the pipeline resources, for exampleresources: XLARGEin the pipeline YAML.- No
gradlewin the repository. It isn't a native Android project. Check the table above.
The Android pipeline guide in the docs covers the full setup, including the Play Store upload. Got a ZIP instead of a repo? See ZIP to APK.