Can someone help me understand why two Gradle daemons are being spawned when I run for i.e. “Clean P...
n
Can someone help me understand why two Gradle daemons are being spawned when I run for i.e. “Clean Project” in Android Studio in a project with
build-tools
as includedBuild? I’ve configured the AS (Otter 2025.2.1) to use the Gradle wrapper (version 8.14.3), but for some reason, another daemon starts up using the 9.0-milestone-1 distribution.
g
maybe another project which has different Gradle wrapper?
does includedBuild has the same version of Gradle?
n
Only one project opened in Android Studio. included-build is similarly structured as build-logic in nowinandroid it has no own wrapper and only gradle related settings are in
build-logic/gradle.properties
Copy code
org.gradle.caching=true
org.gradle.parallel=true
org.gradle.daemon=true

kotlin.compiler.runViaBuildToolsApi=true
kotlin.compiler.execution.strategy=in-process
For example, I’ve run three scenarios, and before each one, I manually deleted
build-logic/.gradle/
build-logic/build/
1. In terminal
./gradlew clean
2. In AS
clean
in gradle tab 3. In AS menu Build -> Clean Project Only 3rd one resulted 9.0-milestone-1 appearing in .gradle folder
Copy code
build-logic/.gradle/8.14.3
build-logic/.gradle/9.0-milestone-1
and daemon with the same version was spawned.
g
1. In AS menu Build -> Clean Project
You should never do this
it probably explains it
but in general, do not use Build menu in AS, it always had very nasty behaviour and not really recommended
n
Any motivation behind this?
Copy code
In AS menu Build -> Clean Project
You should never do this
Sometimes I need to clean build-logic too and it’s the most convenient way to do it as simple ./gradlew clean in root project doesn’t clean
build-logic/build
g
Any motivation behind this?
Because it does it without Gradle and this what you get I believe, it uses standalone gradle to run tasks It was always really bad with Build -> Rebuild, when it run a lot of unnecessary tasks which slowdown you a lot
so in general, you can just do included buildclean or just rm -df whateverYouNeed and add it to run menu maybe
are you sure that you have "clean" task on build-logic?
n
Too be honest it sound like some kind of a bug) At least this daemon don’t consume too much of resources - xmx512m I believe. Thank you for the explanation
are you sure that you have “clean” task on build-logic?
It has clean task, it’s just not being called when I’m running clean in the root project
Copy code
------------------------------------------------------------
Tasks runnable from project ':build-logic'
------------------------------------------------------------

Build tasks
-----------
assemble - Assembles the outputs of this project.
build - Assembles and tests this project.
...
clean - Deletes the build directory.
...
testClasses - Assembles test classes.
g
Probably by strict definition, it's not necessary a bug, more like unclear semantics. If build-logic doesn't have it's own wrapper, studio probably uses built in gradle I didn't check if it actually true, but it matches with other issues that are known with Build menu and why it's not really recommended to use
My advice just avoid it, and do clean with gradle with multiple tasks like
clean :build-logic:clean
you can create a run item if you want to do it from AS But in general you shouldn't use clean so often until you test some performance or debugging some problem
c
i wonder if implementing gradle doctor would fix this. gradle doctor would check if you're using separate jdks inside of studio vs on cmd line and therefore (IIRC) itll spawn a separate gradle daemon. it was written by someone that used to work at gradle https://github.com/runningcode/gradle-doctor
g
@Colton Idle but JDKs are not different, it's just external Gradle used to run build without gradle wrapper Not quite sure how gradle doctor can detect it
🤔 1
How is it even related?
m
It desktop app analysis Android project and storage
g
so how it can help solving this issue?
You as author could demonstrate maybe that it would somehow help, otherwise it looks more like unrelated spam than an actual help
I'm checking features and none of them look related to this
m
Ok sorry I feel it related project because in my project analysis project and gradle wrapper. I am not spam it ok I delete message thank you
g
Yes, if you meant to check your setup, it also not very relevant, because you don't have included build with build logic as OPs project
m
Ok I understand sorry my mistake