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

React Native集成Expo模块打包Google Play报错:Kotlin插件版本不兼容

解决React Native集成Expo模块时Kotlin Gradle插件版本不兼容问题

问题根源

报错里的kotlin-gradle-plugin:1.6.10是Expo模块内部依赖的版本,并非你项目配置文件里直接声明的内容。你的Android Gradle Plugin(AGP)版本要求Kotlin插件至少为1.6.20,因此出现版本冲突。

解决步骤

1. 强制指定Kotlin插件版本到项目根build.gradle

打开项目根目录下的build.gradle(Groovy格式)或build.gradle.kts(Kotlin脚本格式),在buildscript块中添加Kotlin版本的强制声明,覆盖Expo模块的旧版本:

Groovy格式(build.gradle)

buildscript {
    ext {
        // 指定>=1.6.20的稳定版本,推荐使用最新稳定版(如1.8.22)
        kotlinVersion = "1.8.22"
    }
    dependencies {
        classpath("com.android.tools.build:gradle:7.3.0")
        // 显式声明Kotlin Gradle插件,强制覆盖Expo的旧版本
        classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:${kotlinVersion}")
    }
}

Kotlin脚本格式(build.gradle.kts)

buildscript {
    extra["kotlinVersion"] = "1.8.22"
    dependencies {
        classpath("com.android.tools.build:gradle:7.3.0")
        classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:${extra["kotlinVersion"]}")
    }
}

2. 清理缓存并重新构建

执行以下命令彻底清理缓存,避免旧依赖残留:

# 清理Gradle缓存
./gradlew clean

# 清理并重装Node依赖
rm -rf node_modules
npm install

# 重新构建发布包
./gradlew assembleRelease

3. 验证版本生效

构建时查看日志,确认输出中Kotlin Gradle插件的版本为你指定的版本(而非1.6.10),说明版本覆盖成功。

补充说明

你之前看到的修改AGP版本的方案无效,是因为AGP和Kotlin Gradle Plugin是两个独立工具:AGP 7.3.0本身没有问题,但它对Kotlin插件的最低版本要求是1.6.20,而Expo模块自带的Kotlin插件版本达不到要求,因此需要强制覆盖Kotlin插件版本,而非修改AGP版本。

内容的提问来源于stack exchange,提问作者user18899735

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.17 21:35:21