안드로이드 스튜디오 코틀린 프로젝트(앱) 만들기

2021. 9. 18. 23:50[유튜브 강의]- 센치한 개발자/[Android] 코틀린으로 기초 앱만들기 - 강의중

728x90

안드로이드 스튜디오에서 코틀린 프로젝트(앱)를 만드는 일은 너무나 간단하지만

필요한 build.gradle 의 최소한의 dependency 를 정리하고자 기록합니다.

2021.09월 기준 최신 안드로이드 스튜디오 arctic fox 버전에서 코틀린 프로젝트를 생성하면 다음과 같이 생성이 됩니다.

 

프로젝트 레벨에 있는  build.gradle
buildscript {
    repositories {
        google()
        mavenCentral()
    }
    dependencies {
        classpath "com.android.tools.build:gradle:7.0.0"
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.30"

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

 

프로젝트 레벨에 있는 gradle.properties

org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
android.useAndroidX=true
android.enableJetifier=true
kotlin.code.style=official

 

프로젝트 레벨에 있는 settings.gradle
dependencyResolutionManagement {
    repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
    repositories {
        google()
        mavenCentral()
        jcenter() // Warning: this repository is going to shut down soon
        //jcenter()를 사용하지 않는 것이 좋습니다. 
        //(기존 라이브러리들의 업데이트가 중단되었으며, 내려받기만 하는 용도로도 미래가 불투명함.
    }
}
rootProject.name = "sample11"
include ':app'

- write 기능이 중단된 jcenter는 더이상 사용하지 않는 것이 좋습니다.

 

모듈단위  build.gradle
plugins {
    id 'com.android.application'
    id 'kotlin-android'
}

android {
    compileSdk 31

    defaultConfig {
        applicationId "com.sentilab.sample"
        minSdk 23
        targetSdk 31
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }

    buildTypes {
        release {
            minifyEnabled 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 'androidx.core:core-ktx:1.6.0'
    implementation 'androidx.appcompat:appcompat:1.3.1'
    implementation 'com.google.android.material:material:1.4.0'
    implementation 'androidx.constraintlayout:constraintlayout:2.1.0'
    testImplementation 'junit:junit:4.+'
    androidTestImplementation 'androidx.test.ext:junit:1.1.3'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
}

- 현 시점 구글 플레이의 강제 targetSdk 버전 요건인 30 이상도 충족한 31로 셋팅되어 있습니다.

 

안드로이드 최신버전으로 코틀린 프로젝트를 만드는 자세한 순서와 리뷰는 방송에서 한번 확인해주세요

728x90