Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gradle Sync Fails: "Plugin [id: 'com.google.devtools.ksp'] was not found" on a clean project

I'm facing a persistent Gradle sync issue in a brand new Android Studio project and I've run out of all standard solutions. Even after a complete clean install, the problem remains.

The Error: When I try to sync the project, I get the following error:

Plugin [id: 'com.google.devtools.ksp', version: '1.9.24-1.0.19', apply: false] was not found in any of the following sources:
- Gradle Core Plugins (plugin is not in 'org.gradle' namespace)
- Included Builds (No included builds contain this plugin)
- Plugin Repositories (could not resolve plugin artifact 'com.google.devtools.ksp:com.google.devtools.ksp.gradle.plugin:1.9.24-1.0.19')
  Searched in the following repositories:
    Google
    MavenRepo
    Gradle Central Plugin Repository

What I've Tried (and failed):

  1. Clean Install: I have completely uninstalled Android Studio, deleted the C:\Users\<username>\.gradle directory, and deleted the IDE's configuration folders from AppData.
  2. New Project: I created a brand new, empty "Empty Activity (Compose)" project. It synced and ran correctly.
  3. The Problem Trigger: The error appears the moment I try to configure KSP and Room using a version set that should be stable (Kotlin 1.9.24).
  4. Network Test: When I manually try to access the plugin's .pom file URL from the error log (https://plugins.gradle.org/m2/com/google/devtools/ksp/com.google.devtools.ksp.gradle.plugin/1.9.24-1.0.19/...pom) in my browser, I get a 404 Not Found error. This proves it's not a local firewall/network issue, but that the artifact seems to be missing from the repository.
  5. Using Latest Versions: When I try to use the latest default versions from the new project (e.g., Kotlin 2.0.x), I get an IncompatibleClassChangeError, which suggests a deep conflict between the Kotlin compiler and the KSP plugin.

My Configuration Files:

Here is the configuration I am trying to use, which is causing the "Plugin not found" error.

settings.gradle.kts:

pluginManagement {
    repositories {
        google()
        mavenCentral()
        gradlePluginPortal()
    }
}
dependencyResolutionManagement {
    repositories {
        google()
        mavenCentral()
    }
}
rootProject.name = "Chronicle"
include(":app")

build.gradle.kts (Project level):

plugins {
    alias(libs.plugins.android.application) apply false
    alias(libs.plugins.kotlin.android) apply false
    alias(libs.plugins.ksp) apply false
}

libs.versions.toml:

[versions]
agp = "8.2.2"
kotlin = "1.9.24"
ksp = "1.9.24-1.0.19"
room = "2.6.1"
composeCompiler = "1.5.12"
# ... other versions ...

[libraries]
androidx-room-runtime = { group = "androidx.room", name = "room-runtime", version.ref = "room" }
androidx-room-ktx = { group = "androidx.room", name = "room-ktx", version.ref = "room" }
androidx-room-compiler = { group = "androidx.room", name = "room-compiler", version.ref = "room" }
# ... other libraries ...

[plugins]
android-application = { id = "com.android.application", version.ref = "agp" }
kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }
ksp = { id = "com.google.devtools.ksp", version.ref = "ksp" }
kotlin-compose = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "kotlin" }

build.gradle.kts (Module: app):

plugins {
    alias(libs.plugins.android.application)
    alias(libs.plugins.kotlin.android)
    alias(libs.plugins.ksp)
    alias(libs.plugins.kotlin.compose)
}

android {
    // ...
    composeOptions {
        kotlinCompilerExtensionVersion = "1.5.12"
    }
}

dependencies {
    // ...
    implementation(libs.androidx.room.runtime)
    implementation(libs.androidx.room.ktx)
    ksp(libs.androidx.room.compiler)
}

My Question:

How do professional developers handle this? Is there a reliable way to find a "golden set" of compatible versions for AGP, Kotlin, and KSP that are guaranteed to be available in the repositories? It seems bizarre that a standard, documented version would return a 404 error.

Any help would be greatly appreciated. Thanks!

like image 954
Wojtek_pl Avatar asked Oct 21 '25 21:10

Wojtek_pl


2 Answers

It seems bizarre that a standard, documented version would return a 404 error.

I do not know where you see that 1.9.24-1.0.19 is a "standard, documented version".

How do professional developers handle this?

Personally, I go to the KSP GitHub repo and look at the published releases. The only KSP release that I see for last year's 1.9.24 Kotlin release is 1.9.24-1.0.20. I don't see a tag for 1.9.24-1.0.19 either, suggesting that there never was one. Searching for ksp "1.9.24-1.0.19" on multiple search engines also comes up empty, which does not jive with the "standard, documented version" assertion.

If you have evidence that 1.9.24-1.0.19 existed, please post it!

which suggests a deep conflict between the Kotlin compiler and the KSP plugin

In terms of your TOML, ksp needs to have a prefix that matches kotlin. So, for example, if you go with kotlin as 2.2.0, then ksp needs to begin with 2.2.0-, such as 2.2.0-2.0.2.

like image 158
CommonsWare Avatar answered Oct 23 '25 11:10

CommonsWare


I wager this is about versions of kotlin and the order in which to have ksp in your project.

This is how I did it:

my current kotlin version is 2.02

Step 1: add this to your to your module build.gradle.kts as a plugin

id("com.google.devtools.ksp") version "2.2.0-2.0.2"

IMPORTANT: then sync your project

Step 2: then add these to your implementation:

implementation("com.google.dagger:dagger-compiler:2.51.1")
ksp("com.google.dagger:dagger-compiler:2.51.1")

update to latest version then sync your project.

DO NOT ADD ALL THE CODE AT ONCE THEN SYNC YOUR BUILD WILL FAIL LIKE THE WAY MINE DID. Am using Android Studio Narwhal 2025.1.2

Cheers

like image 40
red-x Avatar answered Oct 23 '25 10:10

red-x



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!