How to deploy your Android app to Google Play Store

This guide will walk you through all the steps from adding your Android project to Bitrise to deploying the apk built from your project to Google Play Store.

This guide will walk you through all the steps from adding your Android project to Bitrise to deploying the apk built from your project to Google Play Store.

For this guide, we will use a dummy Android app: sample-apps-android-googleplay

Create your project on Bitrise

First of all, we'll need to set up a project, so:

  1. Open bitrise.io and create a new Bitrise project.
  2. Let Bitrise scan your project and create the initial configuration for your Android project.
  3. Once the scanner has finished working, the generated config will look like this:

'4'xf
default_step_lib_source: https://github.com/bitrise-io/bitrise-steplib.git
project_type: android
trigger_map:
- push_branch: "*"
  workflow: primary
- pull_request_source_branch: "*"
  workflow: primary
workflows:
  deploy:
    steps:
    - activate-ssh-key@3.1.1:
        run_if: '{{getenv "SSH_RSA_PRIVATE_KEY" | ne ""}}'
    - git-clone@4.0.5: {}
    - cache-pull@2.0.1: {}
    - script@1.1.5:
        title: Do anything with Script step
    - install-missing-android-tools@2.0.6: {}
    - gradle-runner@1.8.0:
        inputs:
        - gradle_file: "$GRADLE_BUILD_FILE_PATH"
        - gradle_task: assembleRelease
        - gradlew_path: "$GRADLEW_PATH"
    - deploy-to-bitrise-io@1.3.10: {}
    - cache-push@2.0.3: {}
  primary:
    steps:
    - activate-ssh-key@3.1.1:
        run_if: '{{getenv "SSH_RSA_PRIVATE_KEY" | ne ""}}'
    - git-clone@4.0.5: {}
    - cache-pull@2.0.1: {}
    - script@1.1.5:
        title: Do anything with Script step
    - install-missing-android-tools@2.0.6: {}
    - gradle-runner@1.8.0:
        inputs:
        - gradle_file: "$GRADLE_BUILD_FILE_PATH"
        - gradle_task: assembleDebug
        - gradlew_path: "$GRADLEW_PATH"
    - deploy-to-bitrise-io@1.3.10: {}
    - cache-push@2.0.3: {}
app:
  envs:
  - opts:
      is_expand: false
    GRADLE_BUILD_FILE_PATH: build.gradle
  - opts:
      is_expand: false
    GRADLEW_PATH: "./gradlew"

Copy code

Generate a signed apk

For Android codesigning, we will use the sign-apk Step (read more about this Step here).

Do not forget to upload your keystore file to Bitrise.

After codesign setup the config will look like this:


workflows:
  deploy:
    steps:
    - activate-ssh-key@3.1.1:
        run_if: '{{getenv "SSH_RSA_PRIVATE_KEY" | ne ""}}'
    - git-clone@4.0.5: {}
    - cache-pull@2.0.1: {}
    - script@1.1.5:
        title: Do anything with Script step
    - install-missing-android-tools@2.0.6: {}
    - gradle-runner@1.8.0:
        inputs:
        - gradle_file: "$GRADLE_BUILD_FILE_PATH"
        - gradle_task: assembleRelease
        - gradlew_path: "$GRADLEW_PATH"
    - deploy-to-bitrise-io@1.3.10: {}
    - cache-push@2.0.3: {}
Copy code

Setup a Google Play Store project

If you have ever deployed your app to Google Play Store, skip to no. 3.

To use Google Play Deploy step the following setup has to be done:

  1. Register a Google Play Developer account.
  2. Upload the first release to the Google Play Store.
  • Do not forget to create your app's Store Listing, fill in the content rating questionnaire and set up pricing & distribution.
  • You must upload an APK before filling in the content rating questionnaire. Navigate to your Play Applications App releases page and select either MANAGE ALPHA / MANAGE BETA / MANAGE PRODUCTION, then add your first apk in the APKs to add section and save changes. Click Preview to review your release once more. 😉
  • You do not need to finish the release: once the first apk is uploaded, it is accessible in the Artifacts Library and you can continue with Content Rating.

Once the first upload is done, App releases, Store listing and Content rating should have a green check each on your application's page.

  1. Setup Google Play API access
  • Link your API Project by Creating a new API project or Using an existing API project.
  • Set Up API Access Clients Using a service account and do not forget to download the service account's json key.
  • Grant Release manager role to the Service Account.

At this point, your Google Play console project has been prepared and a services credential account has been created too, which is authorized to manage your releases. Save your service account's json key, you will need it later.

Deploy to Play Store using Bitrise

By now you already have a project on Bitrise which generates a signed apk for you and you have prepared a Google Play project with a service account, which can deploy your apps. Well done, so far. 😎

Now you need to finish your Bitrise workflow:

  1. Go to the Workflow tab of your Bitrise project.
  2. Open the Code Signing tab of the Workflow Editor.
  3. Upload the service account json key into the GENERIC FILE STORAGE and copy the env key which stores your uploaded file's url, let's say: BITRISEIO_SERVICE_ACCOUNT_JSON_KEY_URL
  1. Navigate to the Workflows tab of the Workflow Editor.
  2. Add the Google Play Deploy step next to the Sign APK step.
  3. Fill in the step's required inputs:
  • Service Account JSON key file path: this input can accept a remote url, so just provide the env which holds your uploaded service account json key, for example:  $BITRISEIO_SERVICE_ACCOUNT_JSON_KEY_URL
  • Package name: your Android app's package name
  • Track: the track to which you want to deploy your apk (alpha / beta / rollout / production)

After doing everything described above, the final config will be the following:


workflows:
  deploy:
    steps:
    - activate-ssh-key@3.1.1:
        run_if: '{{getenv "SSH_RSA_PRIVATE_KEY" | ne ""}}'
    - git-clone@4.0.5: {}
    - cache-pull@2.0.1: {}
    - script@1.1.5:
        title: Do anything with Script step
    - install-missing-android-tools@2.0.6: {}
    - gradle-runner@1.8.0:
        inputs:
        - gradle_file: "$GRADLE_BUILD_FILE_PATH"
        - gradle_task: assembleRelease
        - gradlew_path: "$GRADLEW_PATH"
    - sign-apk@1.2.0: {}
    - google-play-deploy@1.4.1:
        inputs:
        - package_name: io.bitrise.googleplay
        - service_account_json_key_path: "$BITRISEIO_SERVICE_ACCOUNT_JSON_KEY_URL"
    - deploy-to-bitrise-io@1.3.10: {}
    - cache-push@2.0.3: {}
Copy code

And you are done!

Happy building!

No items found.

Explore more topics

App development

Best practices from engineers on how to use Bitrise to build better apps, faster.

Community

Meet other Bitrise engineers, technology experts, power users, partners and join our BUGs.

Company

All the updates about Bitrise events, sponsorships, employees, and more.

Insights

Mobile development, latest tech, industry insights, and interviews with experts.

Mobile DevOps

Learn why mobile development is unique and requires a set of unique practices.

Releases

Stay tuned for the last updates, new features, and product improvements.

Get the latest from Bitrise

Join other Mobile DevOps engineers who receive regular emails from Bitrise, filled with tips, news, and best practices.