[Android] gradle groovy → kts 마이그레이션 템플릿
2021. 7. 19. 21:00
androidx처럼 자동 마이그레이션이 안돼서 수동으로 해야함 (첨엔 귀찮지만 바꾸고 나면 문법이 틀린곳을 빌드해보기 전에 IDE에서 미리 알려줘서 좋음)
1. setting.gradle → setting.gradle.kts로 이름 변경
rootProject.name = "Projectname"
include(":app")
2. build.gradle → build.gradle.kts로 이름 변경
app 모듈의 build.gradle
plugins {
id("com.android.application")
id("kotlin-android")
}
android {
compileSdkVersion(30)
defaultConfig {
applicationId = "android.milestone"
minSdkVersion(23)
targetSdkVersion(30)
versionCode = 1
versionName = "1.0"
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
getByName("release") {
isMinifyEnabled = false
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro"
)
}
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = "1.8"
}
}
dependencies {
implementation("org.jetbrains.kotlin:kotlin-stdlib:1.5.20")
implementation("androidx.core:core-ktx:1.6.0")
implementation("androidx.appcompat:appcompat:1.3.0")
implementation("com.google.android.material:material:1.4.0")
implementation("androidx.constraintlayout:constraintlayout:2.0.4")
testImplementation("junit:junit:4.+")
androidTestImplementation("androidx.test.ext:junit:1.1.3")
androidTestImplementation("androidx.test.espresso:espresso-core:3.4.0")
}
프로젝트 최상위 build.gradle
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
mavenCentral()
}
dependencies {
classpath("com.android.tools.build:gradle:4.2.2")
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.20")
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
mavenCentral()
}
}
task("clean", Delete::class) {
delete = setOf(rootProject.buildDir)
}
'if (study) > Android' 카테고리의 다른 글
Android Studio Artic Fox 업데이트 이후 Gradle sync가 안되는 현상 (0) | 2021.09.10 |
---|---|
[Android] 언어별로 폰트 다르게 적용하기 (Apply custom fonts for each language) (2) | 2021.06.22 |
[Android] MotionLayout 내부에서 visibility 변경이 안될 때 (0) | 2021.04.21 |