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

React Native集成Stripe报错:compileDebugKotlin编译任务失败

解决React Native集成Stripe时的task :stripe_stripe-react-native:compileDebugKotlin编译错误

问题背景

使用Kotlin 1.8.21、Gradle 8.1.1构建集成Stripe的React Native项目时,出现编译失败错误:task :stripe_stripe-react-native:compileDebugKotlin failed,尝试多种网上方案后仍未解决。

有效解决方案

以下是经过验证的修复步骤:

1. 同步Kotlin版本与Stripe库兼容性

Stripe React Native库对Kotlin版本有特定要求,将项目的Kotlin版本升级至1.9.0(适配Gradle 8.1.1的兼容版本):

  • 打开项目根目录下的android/build.gradle文件
  • 修改ext块中的Kotlin版本配置:
ext {
    kotlinVersion = "1.9.0"
    // 保留其他原有配置(如minSdkVersion、compileSdkVersion等)
}

2. 确认Stripe库的Gradle引入配置

检查android/settings.gradle中Stripe模块的引入路径是否正确,确保指向node_modules中的对应目录:

include ':stripe_stripe-react-native'
project(':stripe_stripe-react-native').projectDir = new File(rootProject.projectDir, '../node_modules/@stripe/stripe-react-native/android')

3. 清理Gradle缓存并重新构建

执行以下命令清理缓存,避免旧构建文件干扰:

cd android
./gradlew clean
./gradlew assembleDebug

4. 排除冲突的Kotlin依赖(可选)

若存在Kotlin依赖版本冲突,在android/app/build.gradle的dependencies块中添加排除规则:

implementation(project(':stripe_stripe-react-native')) {
    exclude group: 'org.jetbrains.kotlin', module: 'kotlin-stdlib'
}

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.18 21:05:04