---
# System prepended metadata

title: Starting a new Android project

---

# Starting a new Android project

## Repository and Play Store

As a first step let's create a git repository and a new Android Studio project.

- Create a new repository

- Create a new project with Android Studio, then initialise git on that directory and add the repository's URL as the only remote

- Create a debug keystore with this command, leave everything unchanged besides the validity which is expressed in number of days

  `keytool -genkey -v -keystore debug.keystore -storepass android -alias androiddebugkey -keypass android -keyalg RSA -keysize 2048 -validity 18250`

- Create a release keystore with the same command but changing the alias and using strong password(s), e.g. 

  `keytool -genkey -v -keystore release.keystore -storepass {redacted} -alias {app_name} -keypass {redacted} -keyalg RSA -keysize 2048 -validity 18250`

- Create or sign in into the account on Google Play Console, make sure to create the app and fill all the details required (store listing, content rating, accept any policies, ...)

- Enable App Signing which is a process, soon to be mandatory, where Google Play re-signs the app on our behalf. To do that first build a release APK using the release keystore and upload it to the internal track (preferred, but you can pick any other). Now you can enable the App Signing by following the wizard on Google Play Console, keep note of the newly created keystore's SHA signatures.

## Google Developer Console

Create a service account which will give you access to the [Play Developer API](https://developers.google.com/android-publisher/).

- Go to the `API Access` page on Google Play Console, accept the terms and create a new project (and API project will automatically be generated and linked) OR choose the project you'd like to link in case it already exists.

- In the same API Access page under `Service Accounts` click on `Create Service Account`, select which permissions you'd like to add (everything under the `Releases` section should be enough) and you should be able to download the service account json file

Read more [here](https://blog.bitrise.io/how-to-deploy-android-app-to-google-play-store)

## Bitrise CI/CD

Now let's setup the CI/CD pipeline(s) on [Bitrise](https://bitrise.io)

- Under `Workflow > Code Signing` upload your release keystore and fill the alias and the passwords

- Under `Workflow > Code Signing` upload your service account json 

At this point you can use the default workflows automatically created or build your own, just make sure to:

- add a `Sign Apk` step which you can also leave empty as it will read the only keystore you have previously uploaded

- add a `Deploy to Google Play` step when you want to push builds straight to the store by specifying the track (internal, alpha, beta, production) and the service account json which you will find as a input variable

Here's a simple configuration to be used as a valid starting point to tweak the CI/CD ceremony:

```yaml
---
format_version: '8'
default_step_lib_source: https://github.com/bitrise-io/bitrise-steplib.git
project_type: android
trigger_map:
- push_branch: "*"
  workflow: build-and-test
- pull_request_source_branch: "*"
  workflow: build-and-test
workflows:
  deploy:
    steps:
    - activate-ssh-key@4:
        run_if: '{{getenv "SSH_RSA_PRIVATE_KEY" | ne ""}}'
    - git-clone@4: {}
    - cache-pull@2: {}
    - install-missing-android-tools@2:
        inputs:
        - gradlew_path: "$PROJECT_LOCATION/gradlew"
    - change-android-versioncode-and-versionname@1:
        inputs:
        - build_gradle_path: "$PROJECT_LOCATION/$MODULE/build.gradle"
    - android-lint@0:
        inputs:
        - project_location: "$PROJECT_LOCATION"
        - module: "$MODULE"
        - variant: "$VARIANT"
    - android-unit-test@1:
        inputs:
        - project_location: "$PROJECT_LOCATION"
        - module: "$MODULE"
        - variant: "$VARIANT"
    - android-build@0:
        inputs:
        - project_location: "$PROJECT_LOCATION"
        - module: "$MODULE"
        - variant: "$VARIANT"
    - sign-apk@1:
        run_if: '{{getenv "BITRISEIO_ANDROID_KEYSTORE_URL" | ne ""}}'
    - deploy-to-bitrise-io@1: {}
    - cache-push@2: {}
    - google-play-deploy@3:
        inputs:
        - package_name: "$APPLICATION_ID"
  build-and-test:
    steps:
    - activate-ssh-key@4:
        run_if: '{{getenv "SSH_RSA_PRIVATE_KEY" | ne ""}}'
    - git-clone@4: {}
    - cache-pull@2: {}
    - install-missing-android-tools@2:
        inputs:
        - gradlew_path: "$PROJECT_LOCATION/gradlew"
    - change-android-versioncode-and-versionname@1:
        inputs:
        - build_gradle_path: "$PROJECT_LOCATION/$MODULE/build.gradle"
    - android-lint@0:
        inputs:
        - project_location: "$PROJECT_LOCATION"
        - module: "$MODULE"
        - variant: "$VARIANT"
    - android-unit-test@1:
        inputs:
        - project_location: "$PROJECT_LOCATION"
        - module: "$MODULE"
        - variant: "$VARIANT"
    - android-build@0:
        inputs:
        - project_location: "$PROJECT_LOCATION"
        - module: "$MODULE"
        - variant: "$VARIANT"
    - sign-apk@1:
        run_if: '{{getenv "BITRISEIO_ANDROID_KEYSTORE_URL" | ne ""}}'
    - deploy-to-bitrise-io@1: {}
    - cache-push@2: {}
app:
  envs:
  - opts:
      is_expand: false
    PROJECT_LOCATION: "."
  - opts:
      is_expand: false
    MODULE: app
  - opts:
      is_expand: false
    VARIANT: ''
```