Context
To detect whether AGP's built-in Kotlin is enabled, KSP currently uses plugins.findPlugin(KotlinBaseApiPlugin::class.java).
As discussed in https://issuetracker.google.com/476936389, AGP's built-in Kotlin is going to apply an internal subclass of KotlinBaseApiPlugin instead of applying KotlinBaseApiPlugin directly.
That means plugins.findPlugin(KotlinBaseApiPlugin::class.java) will no longer work as it doesn't recognize the subclass of KotlinBaseApiPlugin.
Solution
Instead of
plugins.findPlugin(KotlinBaseApiPlugin::class.java)
please use
plugins.withType(KotlinBaseApiPlugin::class.java).firstOrNull()
(Small note: In theory, there could be multiple subclasses of KotlinBaseApiPlugin, so we use firstOrNull rather than singleOrNull.)
Context
To detect whether AGP's built-in Kotlin is enabled, KSP currently uses
plugins.findPlugin(KotlinBaseApiPlugin::class.java).As discussed in https://issuetracker.google.com/476936389, AGP's built-in Kotlin is going to apply an internal subclass of
KotlinBaseApiPlugininstead of applyingKotlinBaseApiPlugindirectly.That means
plugins.findPlugin(KotlinBaseApiPlugin::class.java)will no longer work as it doesn't recognize the subclass ofKotlinBaseApiPlugin.Solution
Instead of
please use
(Small note: In theory, there could be multiple subclasses of
KotlinBaseApiPlugin, so we usefirstOrNullrather thansingleOrNull.)