1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

【Android】 build生成時に自動生成

Posted at

BuildConfigに追加する

gradle.properties に下記のようにbuildConfigFieldを使って定義する。

gradle.properties.kts(:app)
  defaultConfig {
    ...

    buildConfigField("String", "KEY", "あいうえお")
  }

すると、下記のようにBuildConfigに自動生成される。

BuildConfig.java
  public static final String KEY = "あいうえお";

あとは

MainActivity.kt

    val a: String = BuildConfig.KEY

というように使用できる。

1
1
0

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
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?