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

求助:react-native-photo-manipulator APK构建失败问题

解决react-native-photo-manipulator构建APK时的Kotlin/Gradle兼容性错误

这个错误是Kotlin Gradle插件与项目使用的Gradle版本不兼容导致的,核心原因是IncrementalTaskInputs参数在新版Gradle中已不再适用于@TaskAction注解方法。以下是具体解决措施:

1. 统一Kotlin与Gradle版本匹配

首先确保项目根目录build.gradle中的Kotlin版本和Android Gradle插件版本对应:

  • 若使用Gradle 8.x(对应Android Gradle插件8.x),需搭配Kotlin 1.8.x及以上版本
  • 若使用Gradle 7.x,搭配Kotlin 1.6.x及以上版本

修改根build.gradle:

buildscript {
    ext {
        kotlinVersion = "1.8.22" // 确保和你的Gradle版本匹配
        gradleVersion = "8.1.0"
    }
    dependencies {
        classpath "com.android.tools.build:gradle:$gradleVersion"
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"
    }
}

2. 强制子模块使用统一Kotlin版本

react-native-photo-manipulator可能自带了旧版本的Kotlin配置,需强制所有子模块使用项目指定的版本:
在根build.gradle末尾添加:

subprojects {
    afterEvaluate { project ->
        if (project.plugins.hasPlugin("kotlin-android")) {
            project.ext.kotlinVersion = rootProject.ext.kotlinVersion
            project.dependencies {
                implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlinVersion"
            }
        }
    }
}

3. 清理缓存并重新构建

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

./gradlew clean
./gradlew assembleDebug

4. 升级react-native-photo-manipulator到最新版

该库的旧版本存在Gradle兼容性问题,升级到最新稳定版通常能解决:

npm install react-native-photo-manipulator@latest --save

兼容性说明

这个问题属于库的Gradle配置与项目环境不匹配的常见问题,并非库本身功能缺陷,只要统一Kotlin和Gradle版本即可解决。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.01 04:49:56