任务“:react-native-gesture-handler:compileDebugKotlin”执行失败

Sol*_*ine 5 react-native

失败:构建失败并出现异常。

  • 什么地方出了错: Execution failed for task ':react-native-gesture-handler:compileDebugKotlin'

执行 org.jetbrains.kotlin.compilerRunner.GradleCompilerRunnerWithWorkers$GradleKotlinCompilerWorkAction 时发生失败 编译错误。查看日志了解更多详情

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
Run Code Online (Sandbox Code Playgroud)

[

3m 54s 内构建失败

at makeError (C:\Users\Zsola\Desktop\NoruHotels\node_modules\execa\index.js:174:9)
at C:\Users\Zsola\Desktop\NoruHotels\node_modules\execa\index.js:278:16
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async runOnAllDevices (C:\Users\Zsola\Desktop\NoruHotels\node_modules\@react-native-community\cli-platform-android\build\commands\runAndroid\runOnAllDevices.js:109:5)
at async Command.handleAction (C:\Users\Zsola\Desktop\NoruHotels\node_modules\@react-native-community\cli\build\index.js:192:9)
Run Code Online (Sandbox Code Playgroud)

info 运行 CLI 以--verbose flag获取更多详细信息。

我用ai尝试过这个

当 React-native-gesture-handler 库的 Kotlin 编译过程出现问题时,会出现此错误。您可以采取以下一些步骤来解决该问题:

  1. 确保您安装了正确版本的 Kotlin Gradle 插件。您可以在项目的 build.gradle 文件的依赖项下检查版本。

  2. 尝试通过在项目目录中运行以下命令来清理和重建项目:


cd android
./gradlew clean
cd ..
react-native run-android

Run Code Online (Sandbox Code Playgroud)
  1. 如果问题仍然存在,请尝试通过将以下行添加到项目的 build.gradle 文件来更新您的 Kotlin 版本:

ext.kotlin_version = '1.5.21'

然后更新 Kotlin Gradle 插件版本以匹配:

classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.21"

  1. 如果上述步骤均不起作用,请尝试通过将以下行添加到项目的 build.gradle 文件中来禁用 React-native-gesture-handler 库的 Kotlin 编译:
configurations.all {
    exclude group: 'com.facebook.react', module: 'react-native-gesture-handler'
}
Run Code Online (Sandbox Code Playgroud)

然后再跑react-native run-android

希望这些步骤之一能够为您解决问题。

小智 7

我通过将react-native-gesture-handler升级到版本2.9.0解决了这个问题。

  1. 更新package.json 打开项目的package.json文件并找到the dependency for react-native-gesture-handler. 将版本号更改为“2.9.0”(不要忘记删除^)。它应该看起来像这样:

    "dependencies": {
      "react-native-gesture-handler": "2.9.0",
      // other dependencies...
    }
    
    Run Code Online (Sandbox Code Playgroud)
  2. 卸载该node_modules文件夹。

  3. 跑步npm install

  4. 立即尝试构建您的项目


Hil*_*nry 0

如果错误与 cxx 模块相关,请将其添加classpath("com.android.tools.build:gradle:7.3.1")android/build.gradle.

还检查这个问题