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

执行Android单元测试时遇Could not self-attach to current VM错误求助

Android Studio运行测试用例报错:Could not self-attach to current VM using external process

近两日在Android Studio中运行任意测试用例时,均出现如下错误日志:

Caused by: java.lang.IllegalStateException: Could not self-attach to current VM using external process
    at net.bytebuddy.agent.ByteBuddyAgent.installExternal(ByteBuddyAgent.java:675)
    at net.bytebuddy.agent.ByteBuddyAgent.install(ByteBuddyAgent.java:606)
    at net.bytebuddy.agent.ByteBuddyAgent.install(ByteBuddyAgent.java:586)
    at net.bytebuddy.agent.ByteBuddyAgent.install(ByteBuddyAgent.java:538)
    at net.bytebuddy.agent.ByteBuddyAgent.install(ByteBuddyAgent.java:515)
    at io.mockk.proxy.jvm.JvmMockKAgentFactory.initInstrumentation(JvmMockKAgentFactory.kt:134)
    at io.mockk.proxy.jvm.JvmMockKAgentFactory.init(JvmMockKAgentFactory.kt:34)
    at io.mockk.impl.JvmMockKGateway.<init>(JvmMockKGateway.kt:46)

我已尝试以下解决方案但均无效:

  • 清理缓存并重启
  • 清理Gradle缓存并重启
  • 执行终端命令:
    rm -rfv ~/Library/Application Support/AndroidStudio*
    rm -rfv ~/Library/Preferences/AndroidStudio*
    rm -rfv ~/Library/Caches/AndroidStudio*
    rm -rfv ~/Library/Logs/AndroidStudio*
    rm -rfv ~/.AndroidStudio*
    
  • 更换JDK版本(当前使用11.0.13)
  • 尝试旧版本Android Studio

恳请各位帮忙解决该问题,谢谢!

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.08 08:08:32