Skip to content

Remove use of plugins.findPlugin(KotlinBaseApiPlugin::class.java) to detect built-in Kotlin #2772

Closed

Description

@hungvietnguyen

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.)

Activity

  1. consp1racy commented on Feb 6, 2026

    @consp1racy

    EDIT: The above logic is exclusively used in KotlinCompilerPluginSupportPlugin.applyToCompilation which runs afterEvaluate. False alarm.


    Make sure KSP works as expected when Android Built-in Kotlin is enabled per-module and KSP plugin is declared before AGP, i.e.:

    module/build.gradle

    plugins {
        id("com.google.devtools.ksp")
        id("com.android.library")
        id("com.android.built-in-kotlin")
    }

    gradle.properties

    android.builtInKotlin=false
    
  2. self-assigned this
    on Feb 11, 2026
  3. hfmehmed commented on Feb 12, 2026

    @hfmehmed
    Collaborator

    Fix will be released as part of the 2.3.6 release

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions