https://kotlinlang.org logo
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
  • u

    ursus

    06/24/2021, 1:59 PM
    With android studio, where do the available gradle tasks go?)
    b
    c
    • 3
    • 6
  • u

    ursus

    06/24/2021, 1:59 PM
    just gives me some Dependency thing, I want all the avaiable build tasks etc
    c
    • 2
    • 4
  • r

    rsktash

    06/26/2021, 6:46 PM
    Having dependency circular reference error with multi module project which has sub modules with same names inside different folders. When I rename
    main
    to
    mainui
    it works
    v
    • 2
    • 5
  • j

    Javier

    06/27/2021, 6:14 PM
    I am registering a task and it is automatically run when the IDE syncs. Every single time I press the sync button. When I run
    gradlew build
    , it doesn't run. I tried both,
    register
    and
    create
    , same problem. Is it a bug or is it the expected behavior?
    m
    t
    v
    • 4
    • 35
  • d

    dave08

    06/29/2021, 1:51 PM
    How do I get one module's test configuration to depend on another's test configuration in gradle kotlin dsl?
    b
    c
    v
    • 4
    • 32
  • v

    Vivek Modi

    06/30/2021, 11:06 AM
    Hey i updating kotlin gradle version from 1.4.31 to 1.5.20. It giving error
    Execution failed for task ':app:kaptSelectorDebugKotlin'.
    > A failure occurred while executing org.jetbrains.kotlin.gradle.internal.KaptWithoutKotlincTask$KaptExecutionWorkAction
    > java.lang.reflect.InvocationTargetException (no error message)
    n
    t
    m
    • 4
    • 27
  • d

    Dylan

    07/01/2021, 12:15 PM
    Hey there, I'm trying to upgrade Kotlin's gradle plugin from version 1.5.0 to 1.5.20 but I have the following errors. Upgrading to 1.5.10 shows the same errors. I was able to find the same issue on Stackoverflow, but no answer unfortunately. Do you have any idea?
    ✅ 1
    t
    l
    • 3
    • 3
  • c

    chan

    07/01/2021, 7:47 PM
    Hi everyone, trying to update to Kotlin 1.5.20 and run into a weird error message with Gradle maven publish. Any idea? Works perfectly fine with Kotlin
    1.4.30
    Execution failed for task ':module-common:generatePomFileForMavenJavaPublication'.
    > Could not apply withXml() to generated POM
       > kotlin.KotlinNullPointerException (no error message)* Exception is:
    Caused by: org.gradle.api.UncheckedIOException: Could not write to file '.../module-common/build/publications/mavenJava/pom-default.xml'
    ➕ 2
    t
    • 2
    • 1
  • d

    darkmoon_uk

    07/05/2021, 12:59 AM
    How can I specify an alternate name for the output artfact (e.g.
    someModule-jvm.jar
    ) in my Kotlin Multiplatform project? Asking because I restructured my project to have submodules for Clean architecture layers, so now I have multiple JARs named e.g.
    domain-
    ,
    presentation-
    ,
    service-
    b
    p
    • 3
    • 3
  • j

    Justin Tullgren

    07/09/2021, 1:26 PM
    Hello everyone, I am using a plugin that transitively brings in kotlin 1.4.31 while i am trying to use kotlin 1.5. That gives the warning
    Runtime JAR files in the classpath should have the same version. These files were found in the classpath
    and I can't seem to fix it even by adding the explicit versions in my project. How should this be resolved? Thanks!
    e
    • 2
    • 7
  • f

    Francesc

    07/11/2021, 1:41 AM
    Is there a known issue between AGP 7.1.0-alpha03 and Android coroutines when R8 is enabled? On AGP 7.1.0-alpha02 my app runs fine, but on alpha03 it crashes on launch with R8 enabled. I'm using Kotlin 1.5.10 and coroutines 1.5.0.
    :not-kotlin: 1
    n
    g
    +2
    • 5
    • 26
  • n

    Nikiizvorski

    07/13/2021, 8:30 AM
    Hey guys i have a quick question. I want to exclude a module if it’s not being added to gradle as dependency for jacoco is there a way to do that?
    :not-kotlin: 1
    r
    • 2
    • 2
  • z

    zalewski.se

    07/13/2021, 7:22 PM
    Hello 👋 I’m having issue with gradle sync in Android Studio, I started using TOML version catalog format and inside my build.gradle.kts I always get an error:
    Caused by: ScriptCompilationException(errors=[ScriptCompilationError(message=Unresolved reference: libs, location=/Users/username/.gradle/.tmp/gradle-kotlin-dsl-8359750362388470244.tmp/build.gradle.kts (13:20)),
    My gradle setup looks like this:
    plugins {
        `kotlin-dsl`
        id("com.osacky.doctor") version "0.7.0"
    }
    
    repositories {
        google()
        jcenter()
        mavenCentral()
    }
    
    dependencies {
        implementation(libs.android.gradle)
        implementation(libs.kotlin.gradle.plugin)
        implementation(libs.kotlin.serialization)
        implementation(libs.sqldelight.gradle.plugin)
    }
    
    kotlin {
        explicitApi()
    }
    It works completely fine if I build it from cli. Is this some known error of AS and toml version catalog compatibility or I’m doing something wrong? Gradle wrapper version: 7.1.1 AS: 2021.1.1 Canary 3
    g
    • 2
    • 7
  • u

    ursus

    07/17/2021, 11:11 PM
    Hey, Can someone give advice on configuration avoidance? I have this code where I need a task per variant/output. I use the
    configureEach
    and
    register
    to achieve config. avoidance
    applicationVariants.configureEach { variant ->
        variant.outputs.configureEach { output ->
            def abi = output.getFilter(com.android.build.OutputFile.ABI)
            def abiName = abi.replace("_", "").replace("-", "")
    
            tasks.register("appAutomateUpload${abiName.capitalize()}${variant.name.capitalize()}", AppAutomateUpload) {
                group = "browserstack"
    
                ...
    
                dependsOn "assemble${variant.name.capitalize()}"
            }
        }
    }
    My question is, if only few variants-tasks are actually used, i.e. I for sure don't need all the variant tasks. Should I 1. just do a if ( variant = "...) then return? to not generate a task for that variant at all 2. or, since this is config avoidance, it doesn't matter, since from what I understand, it will be configured lazily, meaning the unused ones won't get configured ever Performance is what I'm after
    v
    • 2
    • 1
  • u

    ursus

    07/17/2021, 11:36 PM
    Also, the task its self appearas to be created lazily, but
    applicationVariants.configureEach { variant ->
            variant.outputs.configureEach { output ->
                  pritln "variant; output"
    prints that even when running
    gradlew help
    ... so...whats the difference
    v
    • 2
    • 3
  • u

    ursus

    07/18/2021, 2:38 AM
    androidComponets {
        onVariants {
            println "variant=$it"
        }
    }
    
    why does this not compile? its eaxcly the official sample
    e
    v
    • 3
    • 10
  • w

    wakingrufus

    07/21/2021, 8:21 PM
    is there a trick to use the kotlin DSL when I am writing a gradle plugin? my build.gradle looks like
    plugins {
        id 'java-gradle-plugin'
        id 'org.jetbrains.kotlin.jvm'
    }
    
    dependencies {
        compileOnly gradleApi()
        implementation "org.scalastyle:scalastyle_2.12:1.0.0"
    
        testCompileOnly gradleApi()
        testCompile 'junit:junit:4.13.1'
        testImplementation "org.junit.jupiter:junit-jupiter-api:$junit5Version"
        testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:$junit5Version"
        testImplementation("org.junit.jupiter:junit-jupiter-params:$junit5Version")
        testImplementation "org.assertj:assertj-core:$assertJVersion"
    }
    and i cant seem to access the
    project.tasks.register<TaskType>(name: String)
    among other things
    c
    t
    +2
    • 5
    • 5
  • d

    Dariusz Kuc

    07/22/2021, 5:46 PM
    Hello 👋 I have a plugin that generates :kotlinnew: source code that is added to the main source set. Since the source code has to be compiled, for convenience I also configured the tasks to be finalized by
    compileKotlin
    /`compileTestKotlin` tasks. This works great for the regular JVM builds but blows up on the Android builds as those tasks don't exist and instead we have variants (e.g.
    compileDebugKotlin
    ). Since I'm not familiar with Android ecosystem was wondering whether anyone here got some suggestions on • how to detect whether plugin is applied on Android project? (check for
    android
    extension?) • how to get all the variants? (get all tasks of compile kotlin type and then apply crude filter looking for
    test
    in the name?) • do I need to add generated sources to different source sets based on variants? • anything else that I might be missing?
    m
    t
    a
    • 4
    • 8
  • s

    spierce7

    07/24/2021, 7:04 PM
    I have 2 questions: 1. Does anyone know how to use the C plugin from Kotlin Script Gradle? The key extension namespace for it is
    model
    , but that doesn’t seem to exist in the kotlin world. 2. if I run
    ./gradlew :project:tasks
    I get a list of tasks for that project. I can do something like this in gradle 6.9:
    def copyDylib = tasks.register('copyDylib', Copy) {
        dependsOn "assembleDependentsMyJniLibrarySharedLibrary"
    
        from(file("$buildDir/libs/myjnilibrary/shared/"))
        into(file("$resourcesPath"))
    }
    But after upgrading to Gradle 7.x, it can no longer find the task
    assembleDependentsMyJniLibrarySharedLibrary
    even though I can call it and it clearly exists. I’ve also tried
    afterEvaluate
    with the same result.
    v
    • 2
    • 6
  • a

    andylamax

    07/26/2021, 2:55 AM
    how do I set
    lintOptions {
            isAbortOnError = false
        }
    In AGP 7.0.0-alpha01 using kotlin-dsl? The above snipet works with AGP 4.1.3, it fails when upgraded to 7.0.0
    :stackoverflow: 1
    a
    • 2
    • 2
  • j

    Jgafner

    07/26/2021, 8:57 AM
    Hi trying to convert gradle groovy to kotlin script
    tasks.register("uiTestCore", Test) {
        it.group("verification")
        // we don't want to cache the results of this.
        it.outputs.upToDateWhen { false }
    
        it.systemProperty("robot-server.port", remoteRobotPort)
    }
    It is failing on the systemProperties and I can’t find an example
    tasks.register<Test>("uiTestCore") {
        group = "verification" // we don't want to cache the results of this.
        outputs.upToDateWhen { false }
        systemProperties("robot-server.port", remoteRobotPort)
    }
    any idea?
    v
    • 2
    • 2
  • s

    Samuel Dobbie

    07/26/2021, 5:10 PM
    Hey, I'm currently using gradle 7.1.1 to set env variables as below (along w/ kotest):
    # build.gradle.kts
    
    tasks.withType<Test> {
        ...
        environment = mapOf(
            "VERSION" to "1.0",
            "TYPE" to "some-type",
            "NAME" to "some-name",
            "PATH" to "some-path",
        )
    }
    Whilst this works, I'm trying to remove this block and instead set these env variables in the bash script show below. The current approach of simply exporting the values doesn't seem to be making them available to the JVM.
    # run-tests.sh
    
    export VERSION=1.0
    export TYPE=some-type
    export NAME=some-name
    export PATH=some-path
    
    ./gradlew test --tests HealthCheck
    Any suggestions on how to resolve this would be much appreciated.
    v
    • 2
    • 2
  • d

    Dariusz Kuc

    07/26/2021, 9:27 PM
    Hello 👋 Any suggestions on how to setup a test android project that can be run using Gradle TestKit on Github Actions? I got a Gradle plugin that I'd like to test against android but it requires
    ANDROID_SDK_ROOT
    (or
    sdk.dir
    to provided) so while I can get it to work locally any suggestions on how to make it a self contained build on GH actions?
    m
    • 2
    • 10
  • t

    Tomasz Krakowiak

    07/27/2021, 5:18 PM
    message has been deleted
    t
    • 2
    • 6
  • d

    Dariusz Kuc

    07/27/2021, 5:23 PM
    Hello 👋 Was wondering what is the proper way to order tasks -> i.e. I have a task that generates :kotlinnew: sources so I finalize it with a corresponding compile task (
    compileKotlin
    in JVM builds and
    compile${Variant}Kotlin
    for :android: ). What is somewhat weird is that for JVM builds my task gets included when running
    build
    goal but on Android it is not.... If I explicitly run my task on Android project it does get finalized correctly. So just wondering what would be the cause of the difference in behavior between JVM and Android builds
    v
    e
    • 3
    • 35
  • k

    kevindmoore

    07/28/2021, 10:14 PM
    Can anyone point me to articles/documentation on gradle for multiplatform? I'm really confused as why I need the
    jvm {} or jvm("desktop")
    in the kotlin section. I am also having problems with a sourceset including another project
    g
    • 2
    • 3
  • e

    eygraber

    07/30/2021, 8:30 PM
    I've noticed that a lot of my
    compile*Kotlin
    tasks have build cache misses (specifically for Android projects building a release variant) even though nothing apparent changed in those modules. What's the best way to debug this?
    t
    • 2
    • 7
  • e

    eygraber

    07/30/2021, 9:59 PM
    I raised the Xmx on my
    kotlin.daemon.jvm.options
    to 12g and now I'm intermittently getting this warning multiple times in my builds (and my builds are going apprx 3-4x slower). The build still completes successfully:
    Could not connect to Kotlin compile daemon
    Could not connect to kotlin daemon. Using fallback strategy.
    t
    a
    d
    • 4
    • 27
  • c

    Christopher Elías

    07/31/2021, 4:57 PM
    Does someone know how to fix this "false-positive" error from the IDE in the gradle files? Im using the latest android studio version on the stable channel (Android Studio Arctic Fox | 2020.3.1) and this is driving me crazy, it's really annoying. The IDE highlight the imports as error but the app still runs/deploy normally
    c
    n
    v
    • 4
    • 7
  • n

    Norbi

    08/01/2021, 4:35 PM
    I have a project including another project using
    includeBuild()
    . I'm using Android Studio Arctic Fox 2020.3.1. When I build it in Idea it seems to succeed, classes referenced from the included build are resolved as well. But in the editors these references remain "red", they cannot be resolved by the editors. Do you have any suggestion how I should investigate the root of the problem?
    v
    • 2
    • 2
Powered by Linen
Title
n

Norbi

08/01/2021, 4:35 PM
I have a project including another project using
includeBuild()
. I'm using Android Studio Arctic Fox 2020.3.1. When I build it in Idea it seems to succeed, classes referenced from the included build are resolved as well. But in the editors these references remain "red", they cannot be resolved by the editors. Do you have any suggestion how I should investigate the root of the problem?
Oh, I've just seen this post: https://kotlinlang.slack.com/archives/C19FD9681/p1627750678012500 Seems to be very similar...
v

Vampire

08/02/2021, 9:44 AM
It's not really similar.
buildSrc
is not an included build, though it is similar in concept and eventually will be made an included build, but that post also is about
buildSrc
classes used in Groovy DSL build scripts. I don't think that is related to your problem with composite builds and usage in production code. So did you say it works properly in IntelliJ or it is "red" there too? If IntelliJ (and thus AS) behaves strange, a first shot in the dark usually is to do "Invalidate caches and restart", maybe that helps already for your case.
View count: 9