You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

迁移PhotoEditor SDK示例代码至Kotlin 1.9.23后Gradle构建失败:找不到KSP插件

迁移PhotoEditor SDK示例代码至Kotlin 1.9.23后Gradle构建失败:找不到KSP插件

我最近在把PhotoEditor SDK集成到Flutter项目里,官方示例用的还是旧版Kotlin 1.7,看着版本太老就把Android端代码迁移到了Kotlin 1.9.23,结果刚迁移完就碰到了Gradle构建失败的问题,根源是Kotlin Symbol Processing(KSP)插件找不到。

完整的错误提示是这样的:

FAILURE: Build failed with an exception.

  • Where: Settings file '/Users/macbook/Documents/Flutter/Projects/Mine/pesdk-flutter/example/android/settings.gradle.kts' line: 25
  • What went wrong:
    Plugin [id: 'com.google.devtools.ksp', version: '1.7.22-1.0.8'] was not found in any of the following sources:
  • Gradle Core Plugins (plugin is not in 'org.gradle' namespace)
  • Plugin Repositories (could not resolve plugin artifact 'com.google.devtools.ksp:com.google.devtools.ksp.gradle.plugin:1.7.22-1.0.8')
    Searched in the following repositories:
    Google
    MavenRepo
    Gradle Central Plugin Repository

别担心,这个问题我帮不少开发者解决过,核心原因就是KSP插件版本和你升级后的Kotlin版本不匹配,而且旧版KSP插件可能已经从仓库下架了,给你几个靠谱的解决步骤:

  • 同步KSP与Kotlin版本:KSP的版本必须和你的Kotlin版本严格对应,Kotlin 1.9.23对应的KSP版本是1.9.23-1.0.17。你需要找到项目里配置KSP插件的地方(一般在settings.gradle.kts或者项目根目录的build.gradle),把原来的1.7.22-1.0.8替换成这个匹配的版本号。

  • 检查插件仓库配置:确保你的Gradle配置里包含了Gradle官方插件仓库,很多人容易漏掉这个。在settings.gradle.kts的pluginManagement块里要加上gradlePluginPortal(),比如:

    pluginManagement {
        repositories {
            gradlePluginPortal() // 这个必须有,KSP插件在这里托管
            google()
            mavenCentral()
        }
    }
    
  • 刷新依赖并清理缓存:有时候旧的Gradle缓存会搞事情,你可以在终端里执行这个命令,强制刷新依赖并清理缓存:

    ./gradlew clean build --refresh-dependencies
    

最后提醒一下,项目里所有和Kotlin相关的依赖(比如kotlin-gradle-plugin)都要统一升级到1.9.23,版本不一致很容易引出其他奇怪的问题哦。

内容来源于stack exchange

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.08 13:58:05