LoginSignup
31

More than 5 years have passed since last update.

gradle.propertiesに定義した値をAndroidManifest.xmlから参照する

Last updated at Posted at 2016-03-26

gradle.propertiesに参照する値を定義します。

gradle.properties
fabricApiKey=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

app.gradlemanifestPlaceholdersを使って変数を登録します。

app.gradle
android {
  defaultConfig {
      manifestPlaceholders = [fabricApiKey: project.property("fabricApiKey")];
  }
}

AndroidManifest.xmlから${fabricApiKey}を参照します。

AndroidManifest.xml
        <meta-data
            android:name="io.fabric.ApiKey"
            android:value="${fabricApiKey}" />

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
31