본문 바로가기
프로그래밍 놀이터/Kotlin, Coroutine

[Kotlin] Kotlin 으로 build gradle 을 작성하자!

by 돼지왕 왕돼지 2020. 8. 10.
반응형


kotlin gradle



https://proandroiddev.com/migrating-android-app-to-gradle-kotlin-dsl-1-0-c903760275a5


-

gradle 4.9 이상 버전부터 사용 가능하다.

Kotlin DSL 은 gradle build script 를 지원하는 kotlin 언어이다.

( 기존에 우리가 쓰던 것은 groovy )



-

Kotlin DSL 은 groovy 방식에 비해 IDE 에서 제공하는 다음의 기능들을 함께 제공한다.


Auto-completion

Content assist

Quick documentation

Navigation to source code

Refactoring and much more



-

android studio 도 최신 버전을 사용하는 것이 추천된다.



-

kts 는 Gradle Kotlin Script 의 확장자이다.

build.gradle 대신 build.gradle.kts 를 작성하면 된다.


기존 build.gradle 을 kts 확장자를 붙이도록 rename 하면 코드도 자동으로 변경된다.

include ‘:app’ -> include(“:app”)



-

android studio version 이 낮으면 아래의 에러를 만날 수 있다.

Internal error:

org.gradle.tooling.BuildException: Could not execute build using Gradle distribution "https:/....4-10-all.zip

...



-

Configuration on demand is not supported by the current version of the Android Gradle plugin since you are using Gradle version 4.6 or above. Suggestion: disable configuration on demand by setting org.gradle.configureondemand=false in your gradle.properties file or use a Gradle version less than 4.6.


위와 같은 메시지가 나오며 compile 이 안 된다면 gradle version up 을 시킬 수도 있고,

Preferences > Build, Execution.. > Compiler 에서 "Configure on demand” 를 uncheck 함으로써도 해결할 수 있다.



-

끝!!!




반응형

댓글