I'm working on migrating our app to AGP 9 with bui...
# android
m
I'm working on migrating our app to AGP 9 with built-in Kotlin and I'm hitting a strange issue when trying to override the Kotlin version as recommended in the AGP docs (top-level
build.gradle.kts
,
buildscript {}
block with classpath entry) 🧵
This is the exact error message I'm getting:
Copy code
Calculating task graph as no cached configuration is available for tasks: assembleDebug

FAILURE: Build failed with an exception.

* Where:
Build file '/home/max/Development/Android/Launcher/app/build.gradle.kts' line: 9

* What went wrong:
An exception occurred applying plugin request [id: 'com.android.application', version: '9.0.1']
> Failed to apply plugin 'com.android.internal.application'.
   > Could not create an instance of type org.jetbrains.kotlin.gradle.plugin.mpp.KotlinAndroidTarget.
      > Could not generate a decorated class for type KotlinAndroidTarget.
         > com/android/build/gradle/api/BaseVariant

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights from a Build Scan (powered by Develocity).
> Get more help at <https://help.gradle.org|https://help.gradle.org>.

BUILD FAILED in 988ms
15 actionable tasks: 15 up-to-date
Configuration cache entry stored.
At first, I thought it would come from one of our plugins, but it's actually the KGP that's still referencing the long-deprecated and since removed
BaseVariant
class.
Did anyone else here already hit this issue in the past?
Fwiw, I'm using AGP 9.0.1 specifically for now and am trying to apply KGP 2.2.20 or 2.3.20, neither of them works.
Without the override, it builds fine, but then it uses 2.2.10 and I'd like to upgrade to 2.4.0 after the migration is complete.
Hm, so moving the classpath declaration to the module level somehow fixes it. I suppose I'll use that for now.
v
Hey now only i searched and learned it using claude ai here is some screenshot I have attached look into it if it could solve the problem