https://kotlinlang.org logo
Title
a

arekolek

03/17/2020, 8:44 AM
in my root
build.gradle
I have
apply from: 'test.gradle.kts'
, then in
test.gradle.kts
I have:
tasks.register("vytibnhcyfugohsjfdbnafvdsa") {

}
After I run Sync Project with Gradle files twice, I get this warning in Android Studio (see image), and the log says
Caused by: org.gradle.api.internal.tasks.DefaultTaskContainer$DuplicateTaskException: Cannot add task 'vytibnhcyfugohsjfdbnafvdsa' as a task with that name already exists.
Am I doing something wrong, or is this is a bug?
f

Francisco Javier Ruiz Rodriguez

03/17/2020, 8:49 AM
Maybe you are adding this file twice?
a

arekolek

03/17/2020, 8:51 AM
certainly not
also:
./gradlew tasks
doesn't give any more information, it prints the task name as expected among other tasks
m

Marc Knaup

03/17/2020, 8:53 AM
You could
println(…)
something before creating the task. Probably and for whatever reason the script is executed twice 😮
🔝 1
a

arekolek

03/17/2020, 3:58 PM
I added
println("vyuogihj")
before
tasks.register
, then I got:
$ ./gradlew tasks | grep vyuogihj              
vyuogihj
also, when I sync with gradle in Android Studio, this is the output
f

Francisco Javier Ruiz Rodriguez

03/17/2020, 4:04 PM
Maybe the best option is to register the tasks only if it doesn't exist. I'm not a gradle expert, but I think the integration between Android Studio and kotlin gradle files are experimental