android {
...
buildTypes {
debug {
// 레이아웃 벨류 사용법
resValue("string", "testvalue", "디버그 모드")
// 자바 벨류 사용법
buildConfigField "String", "TestValue01", "\"디버그 모드\""
buildConfigField "int", "TestValue02", "1234567890"
buildConfigField "boolean", "TestValue03", "true"
}
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
// 레이아웃 벨류 사용법
resValue("string", "testvalue", "릴리즈 모드")
// 자바 벨류 사용법
buildConfigField "String", "TestValue01", "\"릴리즈 모드\""
buildConfigField "int", "TestValue02", "0987654321"
buildConfigField "boolean", "TestValue03", "false"
}
}
}
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- Automatically generated file. DO NOT MODIFY -->
<!-- Values from build type: release -->
<string name="testvalue" translatable="false">릴리즈 모드</string>
</resources>
public final class BuildConfig {
public static final boolean DEBUG = Boolean.parseBoolean("true");
public static final String APPLICATION_ID = "com.linecorp.advertise.buildmodetest";
public static final String BUILD_TYPE = "debug";
public static final String FLAVOR = "";
public static final int VERSION_CODE = 1;
public static final String VERSION_NAME = "1.0";
// Fields from build type: debug
public static final String TestValue01 = "디버그 모드";
public static final int TestValue02 = 1234567890;
public static final boolean TestValue03 = true;
}
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/testvalue" />
TextView testValue01 = findViewById(R.id.txt_testValue01);
testValue01.setText(BuildConfig.TestValue01);
'Developer > Android' 카테고리의 다른 글
[Android Library] 빌드 가능한 안드로이드 라이브러리 모듈 생성 후 다른 프로젝트에 참조하기 (8) | 2018.04.11 |
---|---|
[Android Kotlin] 문자열 템플릿(String Template) 사용법 (0) | 2018.03.15 |
[Android Kotlin] 함수와 변수 - 에디트 텍스트(Edit Text) (0) | 2018.03.14 |
[Android Kotlin] 헬로 코틀린 - 텍스트뷰(TextView), 버튼(Button) (0) | 2018.03.14 |
[Android Kotlin] 안드로이드 스튜디오(Andorid Studio)에 코틀린(Kotlin) 개발환경 셋팅 (0) | 2018.02.10 |