英文:
Execution failed for task ':react-native-gesture-handler:compileDebugKotlin'
问题
FAILURE: 构建失败,出现异常。
- 出了什么问题:
Execution failed for task ':react-native-gesture-handler:compileDebugKotlin'。
> 在执行 org.jetbrains.kotlin.compilerRunner.GradleCompilerRunnerWithWorkers$GradleKotlinCompilerWorkAction 时发生了故障。
> 编译错误。请查看日志以获取更多详细信息 
* 尝试:
> 使用 --stacktrace 选项运行以获取堆栈跟踪。
> 使用 --info 或 --debug 选项运行以获取更多日志输出。
> 使用 --scan 运行以获取完整的见解。
[
- 获取更多帮助:https://help.gradle.org]https://help.gradle.org)
 
构建失败,用时 3 分 54 秒
在执行此操作时发生错误(C:\Users\Zsola\Desktop\NoruHotels\node_modules\execa\index.js:174:9)
在此 (C:\Users\Zsola\Desktop\NoruHotels\node_modules\execa\index.js:278:16)
在此处处理进程任务和拒绝 (node:internal/process/task_queues:95:5)
在所有设备上异步运行 (C:\Users\Zsola\Desktop\NoruHotels\node_modules@react-native-community\cli-platform-android\build\commands\runAndroid\runOnAllDevices.js:109:5)
处理操作 (C:\Users\Zsola\Desktop\NoruHotels\node_modules@react-native-community\cli\build\index.js:192:9)
使用 --verbose 标志运行 CLI 以获取更多详细信息。
我尝试使用AI来解决此问题。
此错误发生在 react-native-gesture-handler 库的 Kotlin 编译过程中存在问题时。以下是解决问题的一些步骤:
- 
确保已安装正确版本的 Kotlin Gradle 插件。您可以在项目的 build.gradle 文件的 dependencies 部分检查版本。
 - 
尝试通过在项目目录中运行以下命令来清理和重新构建项目:
 
cd android
./gradlew clean
cd ..
react-native run-android
- 如果问题仍然存在,请尝试通过在项目的 build.gradle 文件中添加以下行来更新 Kotlin 版本:
 
ext.kotlin_version = '1.5.21'
然后更新 Kotlin Gradle 插件版本以匹配:
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.21"
- 如果以上步骤都不起作用,请尝试通过在项目的 build.gradle 文件中添加以下行来禁用 react-native-gesture-handler 库的 Kotlin 编译:
 
configurations.all {
    exclude group: 'com.facebook.react', module: 'react-native-gesture-handler'
}
然后再次运行 react-native run-android。
希望这些步骤中的其中一项能够解决您的问题。
英文:
FAILURE: Build failed with an exception.
- What went wrong:
Execution failed for task ':react-native-gesture-handler:compileDebugKotlin'.
> A failure occurred while executing org.jetbrains.kotlin.compilerRunner.GradleCompilerRunnerWithWorkers$GradleKotlinCompilerWorkAction
> Compilation error. See log for more details 
* 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.
[
- Get more help at https://help.gradle.org]https://help.gradle.org)
 
BUILD FAILED in 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)
info Run CLI with --verbose flag for more details.
i tried this with ai
This error occurs when there is an issue with the Kotlin compilation process for the react-native-gesture-handler library. Here are some steps you can take to resolve the issue:
- 
Make sure that you have the correct version of Kotlin Gradle Plugin installed. You can check the version in your project's build.gradle file under dependencies.
 - 
Try cleaning and rebuilding your project by running the following commands in your project directory:
 
cd android
./gradlew clean
cd ..
react-native run-android
- If the issue persists, try updating your Kotlin version by adding the following line to your project's build.gradle file:
 
ext.kotlin_version = '1.5.21'
Then update the Kotlin Gradle Plugin version to match:
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.21"
- If none of the above steps work, try disabling Kotlin compilation for the react-native-gesture-handler library by adding the following line to your project's build.gradle file:
 
configurations.all {
    exclude group: 'com.facebook.react', module: 'react-native-gesture-handler'
}
Then run react-native run-android again.
Hopefully one of these steps will resolve the issue for you.
答案1
得分: 5
我将为您翻译代码部分:
"dependencies": {
  "react-native-gesture-handler": "2.9.0",
  // other dependencies...
}
请您继续进行后续步骤。
英文:
I solved it by upgrading my react-native-gesture-handler to version 2.9.0.
- 
Update
package.json:
Open your project'spackage.jsonfile and findthe dependency for react-native-gesture-handler. Change the version number to "2.9.0" (don't forget to remove^). It should look like this:"dependencies": { "react-native-gesture-handler": "2.9.0", // other dependencies... } - 
Uninstall the
node_modulesfolder. - 
Run
npm install - 
Try building your project now
 
答案2
得分: 2
更新我的Android build.gradle buildscript 如下:
buildscript {
    ext {
        buildToolsVersion = '33.0.0'
        minSdkVersion = 21
        compileSdkVersion = 33
        targetSdkVersion = 33
    }
    // 其他部分...
}
对我有用。
英文:
updating my android build.gradle buildscript to
buildscript {
    ext {
        buildToolsVersion = '33.0.0'
        minSdkVersion = 21
        compileSdkVersion = 33
        targetSdkVersion = 33
  }
....
}
worked for me
答案3
得分: 1
安装以下具有特定版本的包,以解决您的错误:
npm i @react-native-community/masked-view@0.1.11 @react-navigation/native@6.0.10 @react-navigation/stack@6.2.1 react-native-gesture-handler@2.4.2 react-native-safe-area-context@4.2.5 react-native-screens@3.2.0 react-navigation@4.4.4
并导入:
import { NavigationContainer } from '@react-navigation/native';
import { createStackNavigator } from '@react-navigation/stack';
英文:
Install the below packages with specific versions that will resolve your error :
npm i @react-native-community/masked-view@0.1.11 @react-navigation/native@6.0.10 @react-navigation/stack@6.2.1 react-native-gesture-handler@2.4.2 react-native-safe-area-context@4.2.5 react-native-screens@3.2.0 react-navigation@4.4.4
and import :
import { NavigationContainer } from '@react-navigation/native';
import { createStackNavigator } from '@react-navigation/stack';
答案4
得分: 0
如果错误与 cxx 模块有关,请在 android/build.gradle 中添加 classpath("com.android.tools.build:gradle:7.3.1")。
另外,请检查此 issue。
英文:
If the error is related to cxx modules, add this classpath("com.android.tools.build:gradle:7.3.1") on android/build.gradle.
Also check this issue
答案5
得分: 0
1: 在 android/build.gradle 中添加一个字符串
kotlinVersion = "1.8.10"
2: 删除 node_modules 文件夹
rm -r node_modules
3: 运行 npm i
4: 运行 npx react-native run-android
还要以管理员身份运行 VS Code(如果你正在使用它)。
英文:
Not sure why, but this seems to solve my problem.
1: Add a String to android/build.gradle
kotlinVersion = "1.8.10"
2: Delete node_modules folder
rm -r node_modules
3:npm i
4:npx react-native run-android
Also run VS code (if you're working in it) as an administrator.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。


评论