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

React Native Expo安卓运行报错:多Kotlin守护进程会话问题求助

解决Expo React Native Android构建时Kotlin多守护进程报错问题

以下是针对该问题的可行解决方法,按顺序尝试:

1. 清理Kotlin守护进程与构建缓存

  • 终止所有运行中的Kotlin守护进程:
    pkill -f kotlin-daemon
    
  • 进入Android目录清理构建产物:
    cd android && ./gradlew clean
    
  • 返回项目根目录,清理Expo缓存:
    expo r -c
    

2. 配置Gradle限制Kotlin守护进程并发数

在项目的android/gradle.properties文件中添加以下配置,强制约束守护进程资源与并发:

kotlin.daemon.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
org.gradle.parallel=false
org.gradle.daemon=false

3. 同步Kotlin版本与Expo兼容要求

打开android/build.gradle文件,确保Kotlin版本适配Expo 6.3.7(推荐使用1.7.20及以上版本):

buildscript {
    ext {
        kotlinVersion = "1.7.20"
    }
    dependencies {
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"
    }
}

4. 调整Parrot OS系统资源限制

Parrot OS默认资源限制可能引发守护进程异常,修改系统配置:

  • 打开资源限制配置文件:
    sudo nano /etc/security/limits.conf
    
  • 添加以下内容(替换your_username为你的系统用户名):
    your_username soft nofile 65536
    your_username hard nofile 65536
    
  • 重启系统后,重新执行expo run:android

5. 降级Expo CLI至稳定版本

若以上方法无效,尝试切换到更稳定的Expo CLI版本:

npm install -g expo-cli@6.2.0

之后清理缓存重新构建项目。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.20 23:22:35