https://kotlinlang.org logo
Docs
Join the conversationJoin Slack
Channels
100daysofcode
100daysofkotlin
100daysofkotlin-2021
advent-of-code
aem
ai
alexa
algeria
algolialibraries
amsterdam
android
android-architecture
android-databinding
android-studio
androidgithubprojects
androidthings
androidx
androidx-xprocessing
anime
anko
announcements
apollo-kotlin
appintro
arabic
argentina
arkenv
arksemdevteam
armenia
arrow
arrow-contributors
arrow-meta
ass
atlanta
atm17
atrium
austin
australia
austria
awesome-kotlin
ballast
bangladesh
barcelona
bayarea
bazel
beepiz-libraries
belgium
berlin
big-data
books
boston
brazil
brikk
budapest
build
build-tools
bulgaria
bydgoszcz
cambodia
canada
carrat
carrat-dev
carrat-feed
chicago
chile
china
chucker
cincinnati-user-group
cli
clikt
cloudfoundry
cn
cobalt
code-coverage
codeforces
codemash-precompiler
codereview
codingame
codingconventions
coimbatore
collaborations
colombia
colorado
communities
competitive-programming
competitivecoding
compiler
compose
compose-android
compose-desktop
compose-hiring
compose-ios
compose-mp
compose-ui-showcase
compose-wear
compose-web
connect-audit-events
corda
cork
coroutines
couchbase
coursera
croatia
cryptography
cscenter-course-2016
cucumber-bdd
cyprus
czech
dagger
data2viz
databinding
datascience
dckotlin
debugging
decompose
decouple
denmark
deprecated
detekt
detekt-hint
dev-core
dfw
docs-revamped
dokka
domain-driven-design
doodle
dsl
dublin
dutch
eap
eclipse
ecuador
edinburgh
education
effective-kotlin
effectivekotlin
emacs
embedded-kotlin
estatik
event21-community-content
events
exposed
failgood
fb-internal-demo
feed
firebase
flow
fluid-libraries
forkhandles
forum
fosdem
fp-in-kotlin
framework-elide
freenode
french
fritz2
fuchsia
functional
funktionale
gamedev
ge-kotlin
general-advice
georgia
geospatial
german-lang
getting-started
github-workflows-kt
glance
godot-kotlin
google-io
gradle
graphic
graphkool
graphql
graphql-kotlin
graviton-browser
greece
grpc
gsoc
gui
hackathons
hacktoberfest
hamburg
hamkrest
helios
helsinki
hexagon
hibernate
hikari-cp
hire-me
hiring
hongkong
hoplite
http4k
hungary
hyderabad
image-processing
india
indonesia
inkremental
intellij
intellij-plugins
intellij-tricks
internships
introduce-yourself
io
ios
iran
israel
istanbulcoders
italian
jackson-kotlin
jadx
japanese
jasync-sql
java-to-kotlin-refactoring
javadevelopers
javafx
javalin
javascript
jdbi
jhipster-kotlin
jobsworldwide
jpa
jshdq
juul-libraries
jvm-ir-backend-feedback
jxadapter
k2-early-adopters
kaal
kafka
kakao
kalasim
kapt
karachi
karg
karlsruhe
kash_shell
kaskade
kbuild
kdbc
kgen-doc-tools
kgraphql
kinta
klaxon
klock
kloudformation
kmdc
kmm-español
kmongo
knbt
knote
koalaql
koans
kobalt
kobweb
kodein
kodex
kohesive
koin
koin-dev
komapper
kondor-json
kong
kontent
kontributors
korau
korean
korge
korim
korio
korlibs
korte
kotest
kotest-contributors
kotless
kotlick
kotlin-asia
kotlin-beam
kotlin-by-example
kotlin-csv
kotlin-data-storage
kotlin-foundation
kotlin-fuel
kotlin-in-action
kotlin-inject
kotlin-latam
kotlin-logging
kotlin-multiplatform-contest
kotlin-mumbai
kotlin-native
kotlin-pakistan
kotlin-plugin
kotlin-pune
kotlin-roadmap
kotlin-samples
kotlin-sap
kotlin-serbia
kotlin-spark
kotlin-szeged
kotlin-website
kotlinacademy
kotlinbot
kotlinconf
kotlindl
kotlinforbeginners
kotlingforbeginners
kotlinlondon
kotlinmad
kotlinprogrammers
kotlinsu
kotlintest
kotlintest-devs
kotlintlv
kotlinultimatechallenge
kotlinx-datetime
kotlinx-files
kotlinx-html
kotrix
kotson
kovenant
kprompt
kraph
krawler
kroto-plus
ksp
ktcc
ktfmt
ktlint
ktor
ktp
kubed
kug-leads
kug-torino
kvision
kweb
lambdaworld_cadiz
lanark
language-evolution
language-proposals
latvia
leakcanary
leedskotlinusergroup
lets-have-fun
libgdx
libkgd
library-development
linkeddata
lithuania
london
losangeles
lottie
love
lychee
macedonia
machinelearningbawas
madrid
malaysia
mathematics
meetkotlin
memes
meta
metro-detroit
mexico
miami
micronaut
minnesota
minutest
mirror
mockk
moko
moldova
monsterpuzzle
montreal
moonbean
morocco
motionlayout
mpapt
mu
multiplatform
mumbai
munich
mvikotlin
mvrx
myndocs-oauth2-server
naming
navigation-architecture-component
nepal
new-mexico
new-zealand
newname
nigeria
nodejs
norway
npm-publish
nyc
oceania
ohio-kotlin-users
oldenburg
oolong
opensource
orbit-mvi
osgi
otpisani
package-search
pakistan
panamá
pattern-matching
pbandk
pdx
peru
philippines
phoenix
pinoy
pocketgitclient
polish
popkorn
portugal
practical-functional-programming
proguard
prozis-android-backup
pyhsikal
python
python-contributors
quasar
random
re
react
reaktive
realm
realworldkotlin
reductor
reduks
redux
redux-kotlin
refactoring-to-kotlin
reflect
refreshversions
reports
result
rethink
revolver
rhein-main
rocksdb
romania
room
rpi-pico
rsocket
russian
russian_feed
russian-kotlinasfirst
rx
rxjava
san-diego
science
scotland
scrcast
scrimage
script
scripting
seattle
serialization
server
sg-user-group
singapore
skia-wasm-interop-temp
skrape-it
slovak
snake
sofl-user-group
southafrica
spacemacs
spain
spanish
speaking
spek
spin
splitties
spotify-mobius
spring
spring-security
squarelibraries
stackoverflow
stacks
stayhungrystayfoolish
stdlib
stlouis
strife-discord-lib
strikt
students
stuttgart
sudan
swagger-gradle-codegen
swarm
sweden
swing
swiss-user-group
switzerland
talking-kotlin
tallinn
tampa
teamcity
tegal
tempe
tensorflow
terminal
test
testing
testtestest
texas
tgbotapi
thailand
tornadofx
touchlab-tools
training
tricity-kotlin-user-group
trójmiasto
truth
tunisia
turkey
turkiye
twitter-feed
uae
udacityindia
uk
ukrainian
uniflow
unkonf
uruguay
utah
uuid
vancouver
vankotlin
vertx
videos
vienna
vietnam
vim
vkug
vuejs
web-mpp
webassembly
webrtc
wimix_sentry
wwdc
zircon
Powered by Linen
gradle
  • o

    Ola Adolfsson

    08/22/2020, 5:21 PM
    Good evening, I have upgraded our multiplatform project from 1.3.72 to 1.4 following the migration guide on kotlinglang. Everything went pretty smooth except that for one project/module where the task ompileKotlinJshangs without any errors or warning. There is no particular difference between the modules and I have no ideas left. Is there a way to debug the gradle task in order to understand what´s happening?
    d
    • 2
    • 4
  • r

    Rodrigo Silva

    08/23/2020, 1:56 PM
    I'm on a project, where every new module I add, it creates the path
    /src/java
    and
    /src/kotlin
    . Where do I change this setting, so that it stops automatically creating that path?
    g
    • 2
    • 1
  • c

    colintheshots

    08/24/2020, 3:43 PM
    Is there a new Kotlin Gradle plugins dependency coming out for Kotlin 1.4.0? 
    implementation("org.gradle.kotlin:plugins:1.3.6")
    is causing incompatibilities with the 1.4.0 Kotlin Gradle plugin because it depends upon 1.3.72. I don't see a newer version out.
    m
    • 2
    • 3
  • d

    droid

    08/24/2020, 9:06 PM
    I recently started noticing that if I try to run Kotest JUnit5 tests class, I am getting this error: org.junit.platform.commons.JUnitException : TestEngine with ID ‘kotest’ failed to discover tests. Any ideas on this?
    w
    • 2
    • 2
  • s

    Sinan Kozak

    08/25/2020, 3:02 PM
    Hi everyone, we need some suggestion around
    kts
    usage for gradle build. We have 140+ modules and we started migrating to
    kts
    from groovy. But our configuration time on CI with fresh project has increased a lot. One
    kts
    file takes almost 1.5 seconds to compile. So it is not scalable, it is not parallel or it doesnt support remote cache. I wonder, is there any planned significant improvement or should we migrate back to groovy?
    o
    n
    c
    • 4
    • 19
  • k

    Kirill Vasilenko

    08/26/2020, 11:04 AM
    Hi everyone! Is it ok to get this error (look at the screenshot) on a fresh project (just created in Idea)? Is there any way to fix it?
    ➕ 1
    m
    • 2
    • 3
  • d

    darkmoon_uk

    08/26/2020, 2:08 PM
    But as soon as I depend on the client and server builds from the 'master' build, their own tasks appear to be inaccessible 🤔
    r
    n
    • 3
    • 3
  • m

    Marian Schubert

    08/28/2020, 4:03 PM
    I'm trying to upgrade to Kotlin 1.4, but I'm getting strange problems with jar's in classpath
    w: Runtime JAR files in the classpath should have the same version. These files were found in the classpath:
        /home/maio/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-reflect/1.4.0/aa2101a19d8688e368ae6e35e8967550ced73884/kotlin-reflect-1.4.0.jar (version 1.4)
        /home/maio/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib-jdk8/1.4.0/e3765b66f0610afc92053ff1a93a87a544fca2b/kotlin-stdlib-jdk8-1.4.0.jar (version 1.4)
        /home/maio/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib-jdk7/1.3.72/3adfc2f4ea4243e01204be8081fe63bde6b12815/kotlin-stdlib-jdk7-1.3.72.jar (version 1.3)
        /home/maio/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib/1.3.72/8032138f12c0180bc4e51fe139d4c52b46db6109/kotlin-stdlib-1.3.72.jar (version 1.3)
        /home/maio/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib-common/1.3.72/6ca8bee3d88957eaaaef077c41c908c9940492d8/kotlin-stdlib-common-1.3.72.jar (version 1.3)
    Any idea why this may happen?
    n
    • 2
    • 2
  • j

    Javier

    08/28/2020, 8:38 PM
    Anyone tried to create a precompiled plugin with android library (agp 4.2.0-alpha08) and kotlin multiplatform plugin (1.4.0)? I am having problem with all the functions used by the multiplatform plugin (sourceSets, implementation, etc)
    • 1
    • 1
  • u

    ursus

    08/28/2020, 11:34 PM
    Hi, I have a beginning of a mono repo which contains 3 apps with shared code. In android studio when I hit the green hammer, all apps are built. This is okay when I want it, but usually is a waste. I can get around it to have a separate settings.gradle on hand, but its kind of annoying to copy paste, and remember not to commit etc
    g
    b
    • 3
    • 11
  • i

    iari

    08/30/2020, 9:35 AM
    I want to update a multi-project build to 1.4.0 and cannot get the gradle configuration to work. I keep getting
    org.gradle.cache.CacheOpenException: Could not open cache directory a12qv6mvmtxif3x5d88rky5rk (C:\Gradle\caches\6.6\gradle-kotlin-dsl\a12qv6mvmtxif3x5d88rky5rk)
    which is caused by
    Caused by: java.lang.IllegalArgumentException: org.gradle.api.internal.initialization.DefaultClassLoaderScope@7c5064e5 must be locked before it can be used to compute a classpath!
    I tried delting the content of
    /build
    folders in all projects/subprojects and all caches in
    C:\Gradle\caches\
    . Found this: https://github.com/gradle/gradle/issues/4823 But to the best of my knowledge, configure-on-demand isn't a thing anymore and I think that i am not using
    evaluationDependsOn
    I don't know how to proceed from here.
    r
    • 2
    • 1
  • j

    Javier

    08/31/2020, 4:41 PM
    I am having problems with gradle lint tasks when
    org.gradle.parallel = true
    d
    n
    • 3
    • 11
  • m

    Mouaad

    09/03/2020, 9:45 AM
    Hello, any idea how to apply
    explicitApi
    to main only (but not for test) using
    freeCompilerArgs
    ?
    i
    • 2
    • 7
  • d

    Davide Giuseppe Farella

    09/06/2020, 7:22 AM
    Good morning, is there a way to check IDE version from Gradle? I got a multiplatform project and script for import modules/composite-builds in my
    gradle.settings.kts
    , but the following problem: • Android Studio doesn’t work well with multiplatform projects yet • Cannot use IntelliJ because I got an Android module with Compose and AGP 4.2, so I got
    This version of the Android Support plugin for IntelliJ IDEA (or Android Studio) cannot open this project, please retry with version 4.2 or newer.
    So I’d like to exclude that Android module when I’m on IntelliJ
    c
    l
    • 3
    • 8
  • o

    orafaaraujo

    09/07/2020, 1:24 PM
    Hi, all Is there any place that I can find which Gradle version should I use based on my AGP?
    b
    • 2
    • 4
  • g

    Giovani Guerra

    09/07/2020, 6:11 PM
    Does creating a kotlin src folder have any benefits? And use like this:
    sourceSets.all {
        java.srcDir("src/$name/kotlin")
    }
    t
    • 2
    • 1
  • d

    Dmitry Motyl

    09/08/2020, 10:53 AM
    Hello all Does possibility exist to import kt-file into build.gradle.kts ?
    g
    n
    • 3
    • 2
  • j

    janvladimirmostert

    09/12/2020, 9:54 AM
    is there a way to always get the latest version of the Kotlin plugin, something like this maybe?
    plugins {
        application
        kotlin("jvm").version("latest")
        maven
    }
    t
    l
    d
    • 4
    • 6
  • r

    Rob Elliot

    09/14/2020, 2:39 PM
    Hi all - can code built in
    buildSrc/src/main/kotlin
    access a constant in
    buildSrc/build.gradle.kts
    ? At the moment I have
    plugins {
      kotlin("jvm") version "1.4.10"
    }
    in
    buildSrc/build.gradle.kts
    and
    const val kotlinVersion = "1.4.10"
    in
    buildSrc/src/main/kotlin/DependencyVersions.kt
    and having to change two files to update kotlin universally rather than one is irritating me.
    l
    j
    • 3
    • 8
  • k

    KV

    09/15/2020, 5:15 AM
    How do I make sure that opening and closing braces have same indentation. Do I need to use any regex for this or is there any rule available? Example :
    //INCORRECT 
    
    viewModel.liveData.observe(this, Observer {
    launch(url(
                locale = Locale.getDefault().language,
                appName = APP_NAME), window.decorView.rootView) })
    //CORRECT
    
    viewModel.liveData.observe(this, Observer {
    launch(
                url(locale = Locale.getDefault().language,  appName = APP_NAME), 
                window.decorView.rootView
          ) 
        })
    n
    • 2
    • 2
  • j

    jean

    09/15/2020, 7:59 PM
    I’ve uploaded my own library over github packages : https://github.com/BeiningBogen/statemachine/packages/398001 Now I’m trying to use it from an android app like so :
    allprojects {
        repositories {
            google()
            jcenter()
            maven {
                name = "GitHubPackages"
                url = uri("<https://maven.pkg.github.com/beiningbogen/statemachine>")
                credentials {
                    username = project.extra["gpr.user"].toString()
                    password = project.extra["gpr.key"].toString()
                }
            }
        }
    }
    ...
    dependencies {
        implementation("no.beiningbogen.StateMachine-jvm:statemachine-jvm:0.1.1")
    }
    but I keep getting
    Failed to resolve: no.beiningbogen.StateMachine-jvm:statemachine-jvm:0.1.1
    Is there a specific thing I need to do with the kotlin dsl to be able to use Maven Pom style dependencies?
    g
    • 2
    • 10
  • p

    peekandpoke

    09/16/2020, 10:01 PM
    Hi everyone! I am in the process of switching my libraries to Kotlin 1.4.10. One of these used annotation processing. And now the task :kaptKotlin fails with the following error:
    > Task :meta:kaptKotlin FAILED
    
    FAILURE: Build failed with an exception.
    
    * What went wrong:
    Execution failed for task ':meta:kaptKotlin'.
    > java.util.zip.ZipException: error in opening zip file
    I am using gradle 6.6.1.
    ------------------------------------------------------------
    Gradle 6.6.1
    ------------------------------------------------------------
    
    Build time:   2020-08-25 16:29:12 UTC
    Revision:     f2d1fb54a951d8b11d25748e4711bec8d128d7e3
    
    Kotlin:       1.3.72
    Groovy:       2.5.12
    Ant:          Apache Ant(TM) version 1.10.8 compiled on May 10 2020
    JVM:          1.8.0_252 (Oracle Corporation 25.252-b09)
    OS:           Linux 5.4.0-7642-generic amd64
    Does anyone have an idea what is going on? I somehow suspect, that the jar file is not created and can therefore not be opened. What should I look for in the gradle logs? Does it matter that the Kotlin version packaged with gradle is 1.3.72?
    n
    • 2
    • 1
  • d

    Daniele B

    09/17/2020, 1:16 PM
    I get this build error:
    Cannot resolve external dependency org.jetbrains.kotlin:kotlin-stdlib-js:1.4.10 because no repositories are defined.
    In my gradle.build.kts file, I actually have not even specified the version:
    implementation(kotlin("stdlib-js"))
    how can I fix this issue?
    j
    i
    • 3
    • 7
  • i

    Isaac

    09/18/2020, 9:50 AM
    So I defined a property in
    gradle.properties
    file and got a reference in the
    build.gradle.kts
    file by declaring a global property:
    val api_key: String by project
    I want to use
    api_key
    in my
    Main.kt
    , but I can't seem to figure out how to gain access. Searched on StackOverflow and all the results were android related. Can anyone help?
    n
    • 2
    • 1
  • d

    Daniele B

    09/18/2020, 6:41 PM
    I have a multiplatform project, with a shared module. When I run “assemble” on the js project, I get this error:
    Execution failed for task ':shared:jsPackageJson'.
    > NPM Dependencies already resolved and installed
    at org.jetbrains.kotlin.gradle.targets.js.npm.KotlinNpmResolutionManager.requireConfiguringState$kotlin_gradle_plugin(KotlinNpmResolutionManager.kt:122)
    at org.jetbrains.kotlin.gradle.targets.js.npm.tasks.KotlinPackageJsonTask.getCompilationResolver(KotlinPackageJsonTask.kt:26)
    at org.jetbrains.kotlin.gradle.targets.js.npm.tasks.KotlinPackageJsonTask.getPackageJson(KotlinPackageJsonTask.kt:50)
    any idea?
    i
    • 2
    • 5
  • s

    Simon Kågedal Reimer

    09/19/2020, 7:28 PM
    As I upgraded a project to use Kotlin 1.4.10 instead of 1.3.60, I got errors because of a version mismatch (stemming from a library that used 1.3.60). I had to solve it by adding this dependency:
    implementation "org.jetbrains.kotlin:kotlin-reflect:1.4.10"
    I would love for the version string here to not contain another hardcoded "1.4.10", but to use whatever the plugin version is at. Is there anyway to do this? We use Groovy Gradle.
    e
    g
    • 3
    • 5
  • a

    Allan Wang

    09/21/2020, 2:56 AM
    Are there examples on how we can use common gradle kts files across other gradle files? Typically, I would apply the kotlin jvm plugin in subprojects and do some configurations. However, if I don’t apply the same plugin in the module specific gradle file, it won’t recognize jvm methods such as
    implementation
    . Is there a way around that?
    e
    j
    • 3
    • 4
  • a

    Allan Wang

    09/23/2020, 6:42 AM
    For gradle plugins, is it possible to auto generate
    resources/META-INF/gradle-plugins/
    from a dsl under
    build.gradle
    ? Similar to how jar creation can specify the manifest info in
    build.gradle
    g
    • 2
    • 2
  • t

    Tower Guidev2

    09/23/2020, 1:43 PM
    Hi, Im trying to build my Android app in AppCenter and its failing because my main app module is called
    my_app
    and not
    app
    How can I configure my
    settings.gradle
    to allow my
    my_app
    module be an alias for
    app
    why isnt this enough ?
    project(':my_app').projectDir = new File(settingsDir, 'app')
    g
    • 2
    • 2
  • s

    Shan

    09/25/2020, 5:53 AM
    Hello all 👋. I've recently ran into an issue where contents of the
    buildSrc
    folder can no longer access the Gradle api. For example:
    //directory: buildsrc/src/main/kotlin/Util.kt
    
    import org.gradle.api.*
    
    fun Project.foo() = doBar()
    Project
    comes up as unresolved. I recently updated to Kotlin 1.4.10 and Gradle 6.6.1, and this is a multi-module project. The `buildSrc`'s
    build.gradle.kts
    file is as it's always been, no changes:
    plugins {
        `kotlin-dsl`
    }
    
    repositories {
        jcenter()
    }
    Any idea what might have caused this, and how I might resolve it? When I try to access
    project.foo()
    from a separate module's
    build.gradle.kts
    file, it hits me with a:
    Overload resolution ambiguity. All these functions match.
    error, and then when I try to go to the declaration it wants me to choose between the actual file that it's declared in (
    buildSrc/src/main/kotlin/Util.kt
    ), and the decompiled java class file. I suspect some change was made in Gradle 6.6.1 with buildSrc dependencies or something but cannot for the life of me figure out what that might be that could be causing this. I've tried explicitly adding the
    gradleApi()
    dependency as well, but no dice. Any help would be appreciated!
    n
    • 2
    • 1
Powered by Linen
Title
s

Shan

09/25/2020, 5:53 AM
Hello all 👋. I've recently ran into an issue where contents of the
buildSrc
folder can no longer access the Gradle api. For example:
//directory: buildsrc/src/main/kotlin/Util.kt

import org.gradle.api.*

fun Project.foo() = doBar()
Project
comes up as unresolved. I recently updated to Kotlin 1.4.10 and Gradle 6.6.1, and this is a multi-module project. The `buildSrc`'s
build.gradle.kts
file is as it's always been, no changes:
plugins {
    `kotlin-dsl`
}

repositories {
    jcenter()
}
Any idea what might have caused this, and how I might resolve it? When I try to access
project.foo()
from a separate module's
build.gradle.kts
file, it hits me with a:
Overload resolution ambiguity. All these functions match.
error, and then when I try to go to the declaration it wants me to choose between the actual file that it's declared in (
buildSrc/src/main/kotlin/Util.kt
), and the decompiled java class file. I suspect some change was made in Gradle 6.6.1 with buildSrc dependencies or something but cannot for the life of me figure out what that might be that could be causing this. I've tried explicitly adding the
gradleApi()
dependency as well, but no dice. Any help would be appreciated!
n

no

09/25/2020, 12:39 PM
Can you share a build scan with the issue?
View count: 12