Android 构建错误:在 build/kotlin/sessions 检测到多个 Kotlin 守护进程会话

use*_*363 6 android-studio react-native

在构建发布包之前,我按照 React Native0.67.4 指令生成密钥并签署配置。该应用程序在 Android 模拟器 (Android Studio) 中运行良好2120.1.1 Patch2。但是在构建发布包时,两者./gradlew assembleRelease都有./gradlew bundleRelease相同的错误,如下所示:

任务:app:signReleaseBundle失败

w: Detected multiple Kotlin daemon sessions at build/kotlin/sessions

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:signReleaseBundle'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.FinalizeBundleTask$BundleToolRunnable
   > java.lang.NullPointerException (no error message)
Run Code Online (Sandbox Code Playgroud)

尝试了帖子中的以下内容

  1. 删除了 ./gradle 下的所有内容和yarn run android
  2. ./gradlew clean 多次

Android studio 2021.1.1 Patch2,Gradle React Native 插件版本 7.2.1/(gradle 7.4.1)

这是其中的一部分package.json

"dependencies": {
    "@ethersproject/shims": "^5.6.0",
    "@react-native-community/toolbar-android": "^0.2.1",
    "@react-native-masked-view/masked-view": "^0.2.6",
    "@react-native-picker/picker": "^2.4.0",
    "@react-navigation/native": "^6.0.8",
    "@react-navigation/stack": "^6.1.1",
    "crypto-js": "^4.1.1",
    "ethers": "^5.6.1",
    "react": "17.0.2",
    "react-native": "0.67.4",
    "react-native-blob-util": "^0.14.1",
    "react-native-confirmation-code-field": "^7.3.0",
    "react-native-device-info": "^8.5.1",
    "react-native-easy-grid": "^0.2.2",
    "react-native-elements": "^3.4.2",
    "react-native-encrypted-storage": "^4.0.2",
    "react-native-flash-message": "^0.2.1",
    "react-native-gesture-handler": "^2.3.2",
    "react-native-get-random-values": "^1.7.2",
    "react-native-gifted-chat": "^0.16.3",
    "react-native-image-picker": "^4.7.3",
    "react-native-loading-spinner-overlay": "^3.0.0",
    "react-native-modal": "^13.0.1",
    "react-native-reanimated": "^2.5.0",
    "react-native-redash": "^16.2.3",
    "react-native-responsive-screen": "^1.4.2",
    "react-native-safe-area-context": "^4.2.2",
    "react-native-screens": "^3.13.1",
    "react-native-vector-icons": "^9.1.0",
    "rn-alioss": "^0.2.5",
    "socket.io-client": "^4.4.1"
  },
  "devDependencies": {
    "@babel/core": "^7.12.9",
    "@babel/runtime": "^7.12.5",
    "@react-native-community/eslint-config": "^2.0.0",
    "babel-jest": "^26.6.3",
    "eslint": "7.14.0",
    "jest": "^26.6.3",
    "metro-react-native-babel-preset": "^0.66.2",
    "react-test-renderer": "17.0.2"
  },
Run Code Online (Sandbox Code Playgroud)

小智 10

我也在各处寻找同一问题的解决方案。最后,经过几个小时的研究,我找到了一个最终对我有用的解决方案,我认为这也可以解决您的问题。

如错误日志所示,我们确实有多个 kotlin 守护进程会话在后台运行。

这个你可以自己检查一下。进入android文件夹并输入

./gradlew --状态

它将显示所有正在运行的守护进程以及进程 ID 及其状态。目前,我们只能阻止他们。

./gradlew --停止

home现在使用终端命令导航到您的目录

cd ~


之后使用删除隐藏的“.gradle”文件夹

sudo rm -rf .gradle


现在您已经删除了所有守护程序缓存,您可以开始全新安装了。

删除node_modules并重新安装软件包
为了安全起见,导航到该android文件夹​​并执行./gradlew clean

现在构建您的反应本机项目!

  • 有一个拼写错误“./gradlew --status”而不是“./gradlew --status” (2认同)