Rightpoint / android-template

A `cookiecutter` template for Android projects
28 stars 4 forks source link

Android Template

CircleCI Android

A template for new Android projects at Rightpoint using Clean Architecture. As this repo is public for the Android communtity, avoid referencing client names in commit messages, issues, PRs, etc.

Inspired by thoughtbot/android-template

What's in the template?

Contributing

We would love your help! View the contributing guide to get started.

Usage

  1. Install cookiecutter:
    • Mac OS: brew install cookiecutter
    • Debian/Ubuntu: sudo apt-get install cookiecutter
  2. Run cookiecutter against the template:
    • Against GitHub repo: cookiecutter gh:Rightpoint/android-template
      • Specify a branch: cookiecutter git@github.com:Rightpoint/android-template.git --checkout {name_of_branch}
    • Local copy: cookiecutter {path/to/android_template_project}
  3. Configure the project properties in the prompt.
  4. Delete anything that is not of interest to your project.

Post Generation

There are a number things that you still need to take care of to get your newly generated project up and running:

  1. Run Gradle Sync in Android Studio to make sure you can build the project.
  2. Generate 3 keystores for your project:
    • Generate a keystore for the develop, sprint and beta tracks
    • Make sure to add the actual keystore files to the repository
    • DO NOT SAVE THE KEYSTORE CREDENTIALS TO THE REPO, USE 1PASSWORD!
    • Utilize the same credentials for all 3 keystores to reduce complexity
    • Try to follow the convention of app name and build flavor for the alias:
      • For example: doormanDevelop, doormanSprint and doormanBeta
    • Update the app/build.gradle file to reflect these keystore values
  3. Create develop and sprint tracks on App Center under the RightpointApps organization or else the App Center API token will not work and a 404 will be thrown when attempting to deploy to App Center. The Rightpoint App Center API token is in the Development vault in 1Password.
  4. Set your project up on CircleCI
  5. Add the following environment variables to CircleCI (A note on the following environment variables: they are prefixed with ORG_GRADLE_PROJECT_ so they can be accessed within our Gradle scripts as project properties. This makes it easier for us to fake them outside of a CI environment.)
    • ORG_GRADLE_PROJECT_APPCENTER_TOKEN set to Rightpoint's App Center token
    • ORG_GRADLE_PROJECT_KEY_PASSWORD set to the keystores' key password
    • ORG_GRADLE_PROJECT_STORE_PASSWORD set to the keystores' store password
    • Any keys that we don't want living in the repo
  6. To get automated code review comments on your pull requests make sure to add the environment variable DANGER_GITHUB_API_TOKEN on CircleCI set to an appropriate Github API token.

How to deal with post-generation build woes

  1. If you decided to launch Android Studio simply click File > Sync Project with Gradle Files to generate a local.properties file.

Android Studio File Menu

  1. If you decided not to launch Android Studio you need to make sure various environment variables are set before you can run any Gradle scripts:
    • You can set the following environment variables with the export command in the terminal
      • ANDROID_HOME=/Users/{your_user}/Library/Android/sdk
      • JAVA_HOME=/Applications/Android\ Studio.app/Contents/jre/jdk/Contents/Home/ (This only needs to be set if you have multiple versions of Java on your machine.)

Dependencies Reference