Deploying Android apps
GitHub

Deploying Android apps

This guide describes how you can add your Android project to bitrise.io and deploy the APK built from your project to Google Play Store. We’re using the sample-apps-android-googleplay app as an example for this tutorial.

In this guide, you will learn how to:

Creating your Android project on bitrise.io

Setting up your first project

  1. Register a Google Play Developer Account. If you already have a Google Play Developer account, and you have already deployed your app to Google Play Store, skip to Set up Google Play API access.
  2. Go through the Prepare & roll out steps.

Setting up Google Play API access

  1. Link your API project by Creating a new API project or Using an existing API project.
  2. Set up API Access Clients using a service account and grant Release manager role to the service account.
  3. Save the downloaded JSON key of your service account now because you will need it later.

Check out the Google Play Developer API guide if you need more information on the process.

You have successfully prepared your Google Play Console project. A services credential account has been created which is authorized to manage your releases.

Deploying to bitrise.io

The Deploy to bitrise.io - Apps, Logs, Artifacts Step attaches all the generated artifacts to your build and uploads them into the  APPS & ARTIFACTS tab on your Build’s page. By default, the value of the Enable public page for the App? input field is set to true. This way, once the build runs, a public install page will be available with a long and random URL which can be shared with others who are not registered on Bitrise.

You can notify user groups or individual users that your APK file has been built by specifying roles and/or email addresses. You can share the app’s public install page with anyone if you set the following input fields:

  1. Go to the Deploy to bitrise.io step.
  2. In the Notify: User Roles input field, add the role (for example, testers, developers, admins) so that only those get notified who have been granted with this particular role.
  3. Or fill out the Notify: Emails input field with email addresses of the users you want to send the URL to. Make sure you set those email addresses as secret env vars! These details can be also modified under Notifications if you click the eye icon next to your generated APK file in the APPS & ARTIFACTS tab. Here you can check the URL by clicking Open Public install page.

Deploying to the Google Play Store

  1. Log in to bitrise.io.
  2. Select your project and go to your Workflow Editor.
  3. Open the Code Signing tab of your Workflow Editor.
  4. Upload the service account JSON key into the GENERIC FILE STORAGE.
  5. Copy the env key which stores your uploaded file’s url.

    For example:

    BITRISEIO_SERVICE_ACCOUNT_JSON_KEY_URL

  6. Go back to your Workflow Editor and add the Google Play Deploy step to the end of your Workflow.
  7. Fill out the required input fields which are:
    • Service Account JSON key file path: This field can accept a remote url so you have to provide the environment which contains your uploaded service account JSON key. For example: $BITRISEIO_SERVICE_ACCOUNT_JSON_KEY_URL
    • Package name: the package name of your Android app
    • Track: the track where you want to deploy your APK (alpha/beta/rollout/production)

The final configuration looks like this:

workflows:
deploy:
  steps:
  - activate-ssh-key@3.1.1:
      run_if: ''
  - git-clone@4.0.11: {}
  - cache-pull@2.0.1: {}
  - script@1.1.5:
      title: Do anything with Script step
  - install-missing-android-tools@2.1.1: {}
  - android-build@0.9.4:
      inputs:
      - project_location: $BITRISE_SOURCE_DIR
      - module: "app"
  - sign-APK@1.2.0: {}
  - google-play-deploy@1.5.0:
      inputs:
      - package_name: io.bitrise.googleplay
      - service_account_json_key_path: "$BITRISEIO_SERVICE_ACCOUNT_JSON_KEY_URL"
      - track: alpha
  - deploy-to-bitrise-io@1.3.12: {}
  - cache-push@2.0.5: {}

Your workflow is ready for deploying your app automatically to Google Play Store. Once the app is tested and generated, you can upload it to Google Play Store.