Android Studio とGradleBuildConfig
プラグインによって生成されたクラスを見ると、ブール値リテラルまたは.BuildConfig.DEBUG
Boolean.parseBoolean(String)
true
false
Gradle を使用してカスタム ビルド プロパティを追加するときは、次のようにします。
android {
buildTypes.debug.buildConfigField 'boolean', 'SOME_SETTING', 'true'
}
しかし、生成されたものを見ると、 Google がフラグBuildConfig
に対して別のアプローチを取っていることがわかります。DEBUG
public final class BuildConfig {
public static final boolean DEBUG = Boolean.parseBoolean("true");
// more fields here
// Fields from build type: debug
public static final boolean SOME_SETTING = true;
}
Boolean.parseBoolean(String)
リテラルの代わりに使用する利点は何ですか?