25
24

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

CircleCI で Android アプリをビルドする時のTIPS

Last updated at Posted at 2015-12-10

Android アプリをビルドするには

基本、circle.yml に設定を記載するだけです。

ビルド設定ファイル サンプル

circle.yml
general:
  artifacts:
    - ./app/build/outputs/apk/
machine:
  java:
    version: oraclejdk7
  environment:
    ANDROID_HOME: /usr/local/android-sdk-linux
test:
  override:
    - echo "Nothing to do here"
  post:
    - ./gradlew compileDevelopReleaseSources
deployment:
  upload:
    branch: [master]
    commands:
      - ./gradlew assembleDevelopRelease
      - ./gradlew uploadDeployGateDevelop
      - ./gradlew assembleProductRelease
      - ./gradlew uploadDeployGateProduct
build.grade
apply plugin: 'com.android.application'
apply plugin: 'deploygate'

android {
...
    signingConfigs {
        release {
            storeFile file('../release.keystore')
            storePassword System.getenv('STORE_PASSWORD')
            keyAlias System.getenv('KEY_ALIAS')
            keyPassword System.getenv('KEY_PASSWORD')
        }
    }
...
}

...
deploygate {
    userName = System.getenv('DEPLOYGATE_USERNAME')
    token = System.getenv('DEPLOYGATE_API_KEY')

    apks {
        product {
            sourceFile = file("./build/outputs/apk/app-product-release.apk")
        }
        develop {
            sourceFile = file("./build/outputs/apk/app-develop-release.apk")
        }
    }
}
...

TIPS 集

共通設定

  • JDK の設定は Oracle JDK 1.7 を使う
  • artifacts は設定しておくと、あとから CircleCI の Webページからapkをダウンロードできる

keystore 関連

  • keystore ファイルは GitHub リポジトリに含める(※非公開リポジトリの場合)
  • key alias と key password は CircleCI の Environment variables に設定する
  • https://circleci.com/docs/environment-variables
  • build.gradle 内では System.getenv(key) で使用できる

デプロイ関連

  • DeployGate 使うのがおすすめ
  • gradle plugin があるのでそれを使う
  • DeployGate の API KEY も Environment variables に設定する

もっとわかりやすいドキュメントないの?

日本語の情報が不足していますので、英語のものも併せて確認するのがよいと思います

25
24
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
25
24

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?