google / ksp

Kotlin Symbol Processing API
https://github.com/google/ksp
Apache License 2.0
2.87k stars 272 forks source link

KSP conflict with KGP, which causes failures with Android Studio #1347

Open skorudzhiev opened 1 year ago

skorudzhiev commented 1 year ago

Incompatibility between KSP and KGP after attempting several different version combinations of the aforementioned plugins. More information can be referenced in the following issue https://issuetracker.google.com/issues/270166324

Caused by: java.lang.NoClassDefFoundError: org/jetbrains/kotlin/gradle/plugin/mpp/pm20/KotlinCompilationData
    at com.google.devtools.ksp.gradle.KspGradleSubplugin.applyToCompilation(KspSubplugin.kt:416)
    at org.jetbrains.kotlin.gradle.plugin.SubpluginEnvironment.addSubpluginOptions(SubpluginEnvironment.kt:49)
    at org.jetbrains.kotlin.gradle.plugin.AndroidProjectHandler$configureTarget$2$1.invoke(AndroidProjectHandler.kt:106)
    at org.jetbrains.kotlin.gradle.plugin.AndroidProjectHandler$configureTarget$2$1.invoke(AndroidProjectHandler.kt:101)
    at org.jetbrains.kotlin.gradle.utils.ForEachAndroidVariantKt$sam$org_gradle_api_Action$0.execute(forEachAndroidVariant.kt)
neetopia commented 1 year ago

The error says it is not able to find KotlinCompilationData, which should be presented in KGP 1.8.10, can you check the KGP version used by AGP 7.4.1?

skorudzhiev commented 1 year ago

I can confirm that the version of KGP that is currently being used is 1.8.10

neetopia commented 1 year ago

Oops, my mistake, I meant checking Gradle version used by AGP.

skorudzhiev commented 1 year ago

The version of Gradle that we use is 7.6

neetopia commented 1 year ago

tried 7.6 Gradle with AGP 7.4.1 in KSP's gradle plugin tests, seems to be working after setting target compatibility to Java 11( won't compile with 8 anyways after upgrading Gradle), can you provide a reproduce link for this?

skorudzhiev commented 1 year ago

I can provide logs if they can help. Please be more specific in your request. This is an issue related to the environment which affects post-built project configuration. Please have a look at the original thread created in the issue tracker and let me know what other type of information might be useful for investigating the problem.

mtotschnig commented 1 year ago

In my case I got this error, in a project where I was using kotlin '1.8.21' with ksp '1.8.10-1.0.9'. Android Studio just showed above error message, but running gradle from the command line, I got the following message:

ksp-1.8.10-1.0.9 is too old for kotlin-1.8.21. Please upgrade ksp or downgrade kotlin-gradle-plugin to 1.8.10.

Upgrading ksp to "1.8.21-1.0.11" solved the problem.

Fly-Felix commented 1 year ago

In my case I got this error, in a project where I was using kotlin '1.8.21' with ksp '1.8.10-1.0.9'. Android Studio just showed above error message, but running gradle from the command line, I got the following message:

ksp-1.8.10-1.0.9 is too old for kotlin-1.8.21. Please upgrade ksp or downgrade kotlin-gradle-plugin to 1.8.10.

Upgrading ksp to "1.8.21-1.0.11" solved the problem.

It worked, thank you very much

gustavobarbosab commented 1 year ago

In my case I got this error, in a project where I was using kotlin '1.8.21' with ksp '1.8.10-1.0.9'. Android Studio just showed above error message, but running gradle from the command line, I got the following message:

ksp-1.8.10-1.0.9 is too old for kotlin-1.8.21. Please upgrade ksp or downgrade kotlin-gradle-plugin to 1.8.10.

Upgrading ksp to "1.8.21-1.0.11" solved the problem.

Thanks, @mtotschnig, it worked for me.

MoatazBadawy commented 1 year ago

In my case I got this error, in a project where I was using kotlin '1.8.21' with ksp '1.8.10-1.0.9'. Android Studio just showed above error message, but running gradle from the command line, I got the following message:

ksp-1.8.10-1.0.9 is too old for kotlin-1.8.21. Please upgrade ksp or downgrade kotlin-gradle-plugin to 1.8.10.

Upgrading ksp to "1.8.21-1.0.11" solved the problem.

Thanks for your solution. You may need to update the Google developers documentation with the new version as the old one failed with most of us. Thanks!

oscar066 commented 1 year ago

In my case I got this error, in a project where I was using kotlin '1.8.21' with ksp '1.8.10-1.0.9'. Android Studio just showed above error message, but running gradle from the command line, I got the following message:

ksp-1.8.10-1.0.9 is too old for kotlin-1.8.21. Please upgrade ksp or downgrade kotlin-gradle-plugin to 1.8.10.

Upgrading ksp to "1.8.21-1.0.11" solved the problem.

Thank you for the solution. In my case, the KSP plugin version 1.8.21-1.0.11 was too old and incompatible with Kotlin version 1.9.0. I resolved the error by updating to KSP version 1.9.0-1.0.13, which is compatible with Kotlin 1.9.0.

Gianguyen1234 commented 1 year ago

I added ksp successfully by using this way: https://youtu.be/skEThDQWLig?si=gtzPnFR-FYgzyQvl

Vcky4 commented 1 year ago

In my case I got this error, in a project where I was using kotlin '1.8.21' with ksp '1.8.10-1.0.9'. Android Studio just showed above error message, but running gradle from the command line, I got the following message:

ksp-1.8.10-1.0.9 is too old for kotlin-1.8.21. Please upgrade ksp or downgrade kotlin-gradle-plugin to 1.8.10.

Upgrading ksp to "1.8.21-1.0.11" solved the problem.

Thanks, this worked for me

hii-deepak commented 11 months ago

In my case I got this error, in a project where I was using kotlin '1.8.21' with ksp '1.8.10-1.0.9'. Android Studio just showed above error message, but running gradle from the command line, I got the following message:

ksp-1.8.10-1.0.9 is too old for kotlin-1.8.21. Please upgrade ksp or downgrade kotlin-gradle-plugin to 1.8.10.

Upgrading ksp to "1.8.21-1.0.11" solved the problem.

It worked, thank you very much

chunkingz commented 9 months ago

In my case I got this error, in a project where I was using kotlin '1.8.21' with ksp '1.8.10-1.0.9'. Android Studio just showed above error message, but running gradle from the command line, I got the following message: ksp-1.8.10-1.0.9 is too old for kotlin-1.8.21. Please upgrade ksp or downgrade kotlin-gradle-plugin to 1.8.10. Upgrading ksp to "1.8.21-1.0.11" solved the problem.

Thank you for the solution. In my case, the KSP plugin version 1.8.21-1.0.11 was too old and incompatible with Kotlin version 1.9.0. I resolved the error by updating to KSP version 1.9.0-1.0.13, which is compatible with Kotlin 1.9.0.

in 2024 this one has worked for me. I guess my question now would be how do we know what version to update to as the docs here don't show it as expected.