英文:
Debug Run In Android Studio Fails With: Instrumentation run failed due to Process crashed
问题
以下是翻译好的部分:
好的,我已经搜索了互联网,但仍然在处理这个问题上遇到困难。我正在开发一个Android库(完整的代码可以在这里找到),问题是,升级到Android Studio Flamingo和其他最新版本后,从UI运行调试停止连接到模拟器或真实设备。我不知道为什么会这样。以下是构建日志,但你可以克隆项目并尝试自己运行它。
它确实显示了测试失败,但是调试器从未附加,我的断点也无用。这使得我非常难以弄清楚为什么它失败了,我的工具到了这一步失败。
我尝试了使用androidx
runner并遵循了这里的说明从头设置我的测试依赖项的解决方案。我尝试排除junit
依赖项,仅使用andriodx
的依赖项,但仍然无法解决问题。我还尝试了清除缓存、无效化和其他显而易见的方法。
英文:
All right, I have scoured the internet and I'm still struggling with this stuff. I have an android library (the full code can be found here) that I'm working on. So gist is, after upgrading to Android studio Flamingo and the other lots to the latest version, the debug run from the UI essentially stopped connecting to either an emulator or a real device. I have no clue why. Below is the build log, but hey you can clone the project and try it yourself.
05/31 21:02:51: Launching 'testldc1()' on Pixel 4 API 30.
Running tests
Open logcat panel for emulator Pixel 4 API 30
Executing tasks: [:mips:connectedDebugAndroidTest] in project /Users/yuck/dev/repos/mips-simulator
> Configure project :mips
AGPBI: {"kind":"warning","text":"The option setting 'android.experimental.testOptions.emulatorSnapshots.maxSnapshotsForTestFailures=0' is experimental.","sources":[{}]}
> Task :mips:preBuild UP-TO-DATE
> Task :mips:preDebugBuild UP-TO-DATE
> Task :mips:generateDebugResValues
> Task :mips:generateDebugResources
> Task :mips:packageDebugResources
> Task :mips:preDebugAndroidTestBuild UP-TO-DATE
> Task :mips:javaPreCompileDebug
> Task :mips:javaPreCompileDebugAndroidTest
> Task :mips:parseDebugLocalResources
> Task :mips:writeDebugAarMetadata
> Task :mips:processDebugManifest
> Task :mips:compileDebugLibraryResources
> Task :mips:generateDebugRFile
> Task :mips:checkDebugAndroidTestAarMetadata
> Task :mips:compileDebugJavaWithJavac
> Task :mips:generateDebugAndroidTestResValues
> Task :mips:mapDebugAndroidTestSourceSetPaths
> Task :mips:generateDebugAndroidTestResources
> Task :mips:bundleLibCompileToJarDebug
> Task :mips:extractDeepLinksDebug
> Task :mips:processDebugAndroidTestManifest
> Task :mips:mergeDebugAndroidTestShaders
> Task :mips:compileDebugAndroidTestShaders NO-SOURCE
> Task :mips:generateDebugAndroidTestAssets UP-TO-DATE
> Task :mips:mergeDebugShaders
> Task :mips:compileDebugShaders NO-SOURCE
> Task :mips:generateDebugAssets UP-TO-DATE
> Task :mips:packageDebugAssets
> Task :mips:mergeDebugAndroidTestAssets
> Task :mips:compressDebugAndroidTestAssets
> Task :mips:processDebugJavaRes NO-SOURCE
> Task :mips:bundleLibResDebug NO-SOURCE
> Task :mips:processDebugAndroidTestJavaRes NO-SOURCE
> Task :mips:mergeDebugAndroidTestResources
> Task :mips:mergeDebugJniLibFolders
> Task :mips:mergeDebugNativeLibs NO-SOURCE
> Task :mips:copyDebugJniLibsProjectOnly
> Task :mips:mergeDebugAndroidTestJniLibFolders
> Task :mips:mergeDebugAndroidTestNativeLibs NO-SOURCE
> Task :mips:desugarDebugAndroidTestFileDependencies
> Task :mips:checkDebugAndroidTestDuplicateClasses
> Task :mips:validateSigningDebugAndroidTest
> Task :mips:bundleLibRuntimeToJarDebug
> Task :mips:writeDebugAndroidTestSigningConfigVersions
> Task :mips:bundleLibRuntimeToDirDebug
> Task :mips:mergeDebugAndroidTestJavaResource
> Task :mips:processDebugAndroidTestResources
> Task :mips:compileDebugAndroidTestJavaWithJavac
> Task :mips:dexBuilderDebugAndroidTest
> Task :mips:mergeLibDexDebugAndroidTest
> Task :mips:mergeProjectDexDebugAndroidTest
> Task :mips:mergeExtDexDebugAndroidTest
> Task :mips:packageDebugAndroidTest
> Task :mips:createDebugAndroidTestApkListingFileRedirect
> Task :mips:connectedDebugAndroidTest
Starting 0 tests on Pixel_4_API_30(AVD) - 11
> Task :mips:connectedDebugAndroidTest FAILED
41 actionable tasks: 41 executed
Test run failed to complete. Instrumentation run failed due to Process crashed.
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':mips:connectedDebugAndroidTest'.
> There were failing tests. See the report at: file:///Users/yuck/dev/repos/mips-simulator/mips/build/reports/androidTests/connected/index.html
* 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
BUILD FAILED in 16s
It does say that test failed which is indeed true, however, the debugger never attached and my break points were pointless. This makes it extremely hard for me figured why it's failing and my tool is failing at this point.
I've used the solutions that suggested using androidx
runner and even followed the instruction here to setup my tests dependencies from scratch. Tried excluding junit
dependency and only have the one from andriodx
but still no go. And cleared cache and invalidate and the other obvious things.
答案1
得分: 2
Go to Edit Configurations -> Debugger -> 将调试类型设置为仅 Java。
答案2
得分: 0
接受的解决方案对我来说行不通,因为我需要调试本地代码。
将最简单的应用项目(比如mipsTest
)与您的库项目一起添加,形成一个“多模块项目”。您可以保持应用程序为空,但确保它包含您的MipsSimulatorTest.java
文件(或者您在androidTest
中选择的任何测试文件)。然后运行/调试您的库测试,它将正常工作,因为它与一个应用程序相关联。
这是一个不太理想的变通方法。我本来期望能够在设备上测试库,因为AndroidJUnitRunner
是无论是库还是应用的托管进程。
英文:
The accepted solution is a non-starter for me since I need to debug native code.
Add the simplest of app projects (say, mipsTest
) alongside your library project, resulting in a "multi-module project". You can leave the app bare but ensure it contains your MipsSimulatorTest.java
file (or whatever test files you choose in androidTest
). Then run/debug your library tests and it will work because it's associated with an app.
This is a bummer of a workaround. I would expect testing a library on device to work because AndroidJUnitRunner
is the hosting process regardless of lib or app.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论