DEV Community

Cover image for Why AI Fails at Bleeding-Edge Updates: Fixing the AGP 9.1.0 + KSP Nightmare
freerave
freerave

Posted on

Why AI Fails at Bleeding-Edge Updates: Fixing the AGP 9.1.0 + KSP Nightmare

We all love the thrill of updating our tech stack. Moving to Android Gradle Plugin (AGP) 9.1.0, Kotlin 2.3.10, and KSP 2.3.6 promises massive performance boosts and built-in Kotlin support.

But then, you hit the build button, and boom:

Using kotlin.sourceSets DSL to add Kotlin sources is not allowed with built-in Kotlin.
Solution: Use android.sourceSets DSL instead.

In the modern era of coding, your first instinct is probably to paste this error into ChatGPT, Gemini, or Claude. Here is why that is a terrible idea for fast-moving frameworks.

The AI Trap: Fast Frameworks vs. Slow Training Data

AI models are incredible tools, but they have a massive blind spot: they cannot keep up with the daily, aggressive update cycles of ecosystems like Kotlin, Android, or Flutter. When you ask an AI to fix a bleeding-edge AGP 9.1.0 error, it relies on its training data, which is heavily populated with legacy solutions. The AI will confidently tell you to add these "band-aid" flags to your gradle.properties:

# ❌ The AI "Hallucination" Fix
android.builtInKotlin=false
android.newDsl=false
android.disallowKotlinSourceSets=false

Enter fullscreen mode Exit fullscreen mode

Do NOT do this. This doesn't fix the problem; it turns off the very features you upgraded to AGP 9.1.0 to get! The AI is essentially telling you to buy a sports car and replace its engine with a lawnmower's.

The Old-School Way: RTFD & The Community

To solve bleeding-edge problems, you have to go back to the old method: searching the error, reading GitHub issues, and checking StackOverflow. Human developers discussing the problem in real-time will always beat an AI relying on outdated documentation.

By doing a manual search, you quickly discover what is actually happening:

  1. The GitHub Issue: Over at the official KSP repository, Issue #2615 highlights the exact clash between KSP and AGP 9.x's new built-in Kotlin architecture. The KSP team was actively working on it.
  2. The StackOverflow Thread: Real developers figuring out the mess in real-time, like in this thread: Using kotlin.sourceSets DSL to add Kotlin sources is not allowed with built-in Kotlin.

The community consensus? The fix isn't a workaround flag; it's simply aligning your versions properly and removing legacy plugins.

The Real, Clean Solution

Here is how you actually migrate to AGP 9.1.0 with KSP, without any dirty hacks in your gradle.properties.

1. Update your Version Catalog (libs.versions.toml):
Ensure you are using the specific KSP version that natively supports the AGP 9.x built-in Kotlin.

[versions]
agp = "9.1.0"
kotlin = "2.3.10"
ksp = "2.3.6" # The actual fix that handles the DSL correctly

Enter fullscreen mode Exit fullscreen mode

2. Clean up your Build Scripts:
Since AGP 9.1.0 handles Kotlin internally, you must remove the old Kotlin Android plugin completely.

In your project-level build.gradle.kts:

plugins {
    alias(libs.plugins.android.application) apply false
    // alias(libs.plugins.kotlin.android) apply false  <-- REMOVE THIS!
    alias(libs.plugins.ksp) apply false
}

Enter fullscreen mode Exit fullscreen mode

In your app-level build.gradle.kts:

plugins {
    alias(libs.plugins.android.application)
    // kotlin("android") <-- REMOVE THIS!
    alias(libs.plugins.ksp)
}

Enter fullscreen mode Exit fullscreen mode

The Moral of the Story

AI is a fantastic co-pilot for writing boilerplate code or explaining fundamental concepts. But when you are dealing with cutting-edge updates in fast-paced environments (Android, Flutter, Next.js, etc.), the AI will fail you.

When you encounter a fresh error after a version bump, don't rely fully on AI. Go back to the old methods: search the error, check the GitHub issues, and trust the community. Sometimes, the AI is telling you to climb through the window when the community has already built a proper door.

Happy Clean Coding!

Top comments (0)