Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fail to apply ksp before android #2174

Closed
ting-yuan opened this issue Oct 25, 2024 · 1 comment · Fixed by #2183
Closed

Fail to apply ksp before android #2174

ting-yuan opened this issue Oct 25, 2024 · 1 comment · Fixed by #2183
Milestone

Comments

@ting-yuan
Copy link
Collaborator

Discussion on Slack: https://kotlinlang.slack.com/archives/C013BA8EQSE/p1729789842772099

People reporting that after updating to ksp 1.0.26 they got the following error in all the modules that have the ksp line before the android one. Was not the case for as far as this project existed and the first versions of ksp.

> Failed to apply plugin class 'org.jetbrains.kotlin.gradle.plugin.KotlinBaseApiPlugin'.
   > Extension with name 'android' does not exist. Currently registered extension names: [ext, sonar, sonarqube, libs, versionCatalogs, projects, ksp, base, defaultArtifacts, spotless, reporting, detekt]
@scott-pollom
Copy link
Contributor

This is caused by this Gradle bug.

There is a workaround that should work, so I'll work on a implementing that.

scott-pollom added a commit to scott-pollom/ksp that referenced this issue Oct 31, 2024
Previously, when the KSP plugin was applied before AGP and AGP's
built-in Kotlin support for test fixtures or screenshot tests was
enabled, there would be an error when building.

The underlying cause for this error is
gradle/gradle#31092, which caused the KSP
plugin to try to access the android extension before AGP's apply method
had completed.

This change fixes the problem by using the "com.android.base" plugin as
the indicator that a module is an Android module. The "com.android.base"
plugin is applied after the android extension has been added, so it
works around the Gradle bug.

Bug: google#2174
Test: GradleCompilationTest
scott-pollom added a commit to scott-pollom/ksp that referenced this issue Oct 31, 2024
Previously, when the KSP plugin was applied before AGP and AGP's
built-in Kotlin support for test fixtures or screenshot tests was
enabled, there would be an error when building.

The underlying cause for this error is
gradle/gradle#31092, which caused the KSP
plugin to try to access the android extension before AGP's apply method
had completed.

This change fixes the problem by using the "com.android.base" plugin as
the indicator that a module is an Android module. The "com.android.base"
plugin is applied after the android extension has been added, so it
works around the Gradle bug.

Bug: google#2174
Test: GradleCompilationTest
@ting-yuan ting-yuan linked a pull request Nov 1, 2024 that will close this issue
ting-yuan pushed a commit that referenced this issue Nov 1, 2024
Previously, when the KSP plugin was applied before AGP and AGP's
built-in Kotlin support for test fixtures or screenshot tests was
enabled, there would be an error when building.

The underlying cause for this error is
gradle/gradle#31092, which caused the KSP
plugin to try to access the android extension before AGP's apply method
had completed.

This change fixes the problem by using the "com.android.base" plugin as
the indicator that a module is an Android module. The "com.android.base"
plugin is applied after the android extension has been added, so it
works around the Gradle bug.

Bug: #2174
Test: GradleCompilationTest
github-actions bot pushed a commit that referenced this issue Nov 1, 2024
Previously, when the KSP plugin was applied before AGP and AGP's
built-in Kotlin support for test fixtures or screenshot tests was
enabled, there would be an error when building.

The underlying cause for this error is
gradle/gradle#31092, which caused the KSP
plugin to try to access the android extension before AGP's apply method
had completed.

This change fixes the problem by using the "com.android.base" plugin as
the indicator that a module is an Android module. The "com.android.base"
plugin is applied after the android extension has been added, so it
works around the Gradle bug.

Bug: #2174
Test: GradleCompilationTest
(cherry picked from commit 5b1cd4a)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants