Qiita Teams that are logged in
You are not logged in to any team

Log in to Qiita Team
Community
OrganizationEventAdvent CalendarQiitadon (β)
Service
Qiita JobsQiita ZineQiita Blog
53
Help us understand the problem. What are the problem?

More than 5 years have passed since last update.

@KeithYokoma

Gradle で複数種類の apk をビルドする

複数種類の apk(ステージング用、リリース用など)をビルドするスクリプト。
プロジェクトのroot以下に、confディレクトリを掘って、その中にkeystoreファイルを置くスタイル。debug 用のはリポジトリに入れておくと良さそう。release 用のは入れるとまずいので、そこだけ頑張らないといけない。

android {
    // ...

    // デバッグ用 apk とリリース用 apk の署名の設定
    signingConfigs {
        debug {
            storeFile file("conf/debug.keystore")
            storePassword "android"
            keyAlias "androiddebugkey"
            keyPassword "android"
        }
        release {
            storeFile file("conf/release.keystore")
            storePassword "fugafugahogehoge"
            keyAlias "yokomark"
            keyPassword "foobarbaz"
        }
    }

    // ビルドの種類に応じて、ビルド時に実行するステップを設定
    buildTypes {
        release {
            debuggable false
            zipAlign true
            runProguard true
            proguardFile getDefaultProguardFile('proguard-android-optimize.txt')
            signingConfig signingConfigs.release
        }
        debug {
            debuggable true
            zipAlign true
            runProguard false
            signingConfig signingConfigs.debug
        }
    }

    productFlavors {
        staging {
            proguardFile 'proguard-rules.txt'
            packageName "jp.yokomark.foo.staging"
        }

        production {
            proguardFile 'proguard-rules.txt'
            packageName "jp.yokomark.foo.product"
        }
    }
}
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
53
Help us understand the problem. What are the problem?