How to deploy only a specific Android APK?

Here’s how you can configure your project to only deploy specific APK(s), and not all of the APKs generated during the Android/Gradle build:

Note: of course to actually deploy an APK you’ll need a deploy step to be included in your Workflow, after the step which generated the APK, e.g. a Deploy to step after the Gradle Runner step.

Specify in your Gradle configs

You can tweak your Gradle configs to not to generate that APK for the task you run.

If you run the assemble gradle task, that generates both a Debug and a Release APK by default.

To only generate a debug APK you can specify the assembleDebug task for the Gradle Runner step, and assembleRelease for a release signed APK. These gradle tasks are valid for a standard / default gradle project, if you have other flavors or modified your gradle configs adapt accordingly. To get all the available gradle tasks in your project, run gradle tasks or gradlew tasks in your gradle project directory.

To set the Gradle task to run with bitrise, you can either specify the task as the Gradle task to run option of the Gradle Runner step, or if you use an App Env Var to specify the task (the auto generated config does) you can find the related environment variable in App Env Vars and you can change the task there as well (you can still specify it directly for the Gradle Runner step too, it’s up to you which solution you prefer).

Set a filter for Gradle Runner step

Alternatively, you can tweak / set the Gradle Runner step’s APK file include filter input.

The default value is *.apk, to copy all generated APKs into the deploy directory, but you can change this to e.g. */app-debug.apk to only copy the app-debug.apk to the deploy directory.

You can use a wildcard pattern, like *.apk to find all apk files. To deploy only app1.apk you can use the pattern */app1.apk, or specify the full path (can be relative, e.g. ./app/build/outputs/apk/app1.apk or */app/build/outputs/apk/app1.apk) or part of the path with a wildcard prefix (e.g. */outputs/apk/app1.apk).

Basically you specify a pattern for the path, not just for the file name, but you can use wildcards in the path, e.g. */apk/app1.apk to find app1.apk in the apk directory, anywhere under the source directory.

Use multiple deploy steps and set specific path(s)

Last but not least you can also use separate deploy steps.

E.g. to deploy two APKs you can use two Deploy to steps, and set the Deploy directory or file path input of the steps to the file paths you want to deploy.

With this solution you can also separately control e.g. the Notifications / emails you want to receive. You can for example deploy both APKs (attach to the build), but you can configure the notifications so that you’ll only receive an email for one of the APKs.

You can find more information about how you can customize the Deploy to step to attach any artifact to the build on our DevCenter at:

If you have any questions just let us know!
Happy Building! :slight_smile: