Gradle builds fall back to compiling without the Kotlin daemon
Failed to compile with Kotlin daemon: java.lang.RuntimeException: Could not connect to Kotlin compile daemonShort answer
The Kotlin compiler normally runs in its own daemon. When Gradle cannot talk to it, the compiler falls back to running inside the Gradle process and prints this warning. Stop all Gradle daemons first. If it keeps coming back, set kotlin.compiler.execution.strategy=in-process, or turn the fallback off to see the real startup error.
Fix it fast
1Find out which cause you have
List the running Gradle daemons. A stale or busy one from another Java version is the first thing to remove.
.\gradlew.bat --status .\gradlew.bat --stop2Match what you see, then jump to its fix
What does the error look like?
Failed to compile with Kotlin daemon: java.lang.RuntimeException: Could not connect to Kotlin compile daemonUsing fallback strategy: Compile without Kotlin daemonTry ./gradlew --stop if this issue persists.
Cause 1 of 2
A stale daemon blocks communication
1Check
Gradle reuses a daemon only when the Java version, JVM attributes and Gradle version match, so old daemons from a previous setup can pile up. The Kotlin documentation itself suggests stopping them.
.\gradlew.bat --status2Fix
Stop the daemons and build again.
.\gradlew.bat --stop3Verify
Run the build; the fallback warning is gone.
.\gradlew.bat assembleDebugConfirmed by docs.gradle.org
Cause 2 of 2
The daemon cannot be reached in this environment
1Check
Switch off the silent fallback so the build fails and prints the real daemon startup or communication problem, instead of continuing slowly.
# gradle.properties
kotlin.daemon.useFallbackStrategy=false2Fix
If you cannot fix the cause, run the compiler inside the Gradle process. The compiler then runs inside the Gradle process and does not need the daemon.
# gradle.properties
kotlin.compiler.execution.strategy=in-process3Verify
Build again; no daemon warning appears and the compile step completes.
.\gradlew.bat assembleDebug --infoConfirmed by kotlinlang.org
How do I stop it coming back?
- Run ./gradlew --stop after changing the JDK or Gradle version.
- Keep one JDK for the project instead of mixing Studio's and a terminal's.
- Do not leave the in-process strategy on for good unless the daemon cannot work on that machine.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.
Which stack is behind this page?
Projects of mine built on the same technologies:
- QistLockA NestJS and React SaaS driving an Android Device Owner agent that locks financed phones when payments lapse.
- Nuclear Home VideoA video-streaming Android app built from scratch, engineered for smooth playback.
- Dispatch ProA real-time logistics platform: Flutter apps, Spring Boot services and a Kafka event pipeline on AWS.
Related fixes
Mobile apps
AGP 9 marks the android block as deprecated or fails on BaseExtension
java.lang.ClassCastException: class com.android.build.gradle.internal.dsl.ApplicationExtensionImpl$AgpDecorated_Decorated cannot be cast to class com.android.build.gradle.BaseExtension
AGP 9.0 uses only the new public DSL interfaces.
3 causes, each with a fixMobile apps
The editor cannot find R, so every R.string and R.id turns red
Unresolved reference: R
R is a class that the build generates from your res folder, in the package named by the module's namespace.
4 causes, each with a fixMobile apps
Android Studio says it could not identify the launch activity when you press Run
Run > Edit Configurations > Launch Options is set to Nothing or to a class that no longer exists
Android Studio launches the activity marked with a MAIN action and a LAUNCHER category in the merged manifest.
3 causes, each with a fixMobile apps
FirebaseInstanceIdService and FirebaseInstanceId.getToken() no longer work
Deprecation warning on FirebaseInstanceId.getInstance().getToken()
Move token handling into a class that extends FirebaseMessagingService and override onNewToken, which runs when a token is first created and whenever it changes.
2 causes, each with a fixMobile apps
Java and Kotlin compile to different JVM targets in an Android module
Inconsistent JVM-target compatibility detected for tasks 'compileDebugJavaWithJavac' (1.8) and 'kaptGenerateStubsDebugKotlin' (17)
Java and Kotlin tasks in the same module are compiling for different JVM targets, for example 1.8 and 17.
2 causes, each with a fixMobile apps
Manifest.permission.POST_NOTIFICATIONS shows red or does not resolve
Cannot resolve symbol 'POST_NOTIFICATIONS'
POST_NOTIFICATIONS exists only from API level 33.
4 causes, each with a fix