Android test project is crashing with error “Test run failed: Instrumentation run failed due to 'Process crashed.'”

牧云@^-^@ 提交于 2019-12-04 00:02:31
  1. Don't attach more than one robotium library. robotium-solo-1.6.0.jar should be removed. It's deprecated and you really shouldn't use it anymore.

  2. Is your target application already installed? It should be installed, if you are going to run tests for it. You can not install it only if your test project has reference to target project.

  3. If you have separate APKs for application and instrumentation you should change package in your manifest. You actually have "com.testcalculator" and target package is the same - they should be different. By the way I don't see sources of application in your project, so application part should be removed.

  4. Your error doesn't say much, it's always good to post stacktrace from LogCat.

  5. Read manuals before you start writing tests:

    http://developer.android.com/tools/testing/testing_android.html https://code.google.com/p/robotium/w/list

For those migrating to or currently using Androidx, this error results from using testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" instead of testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner".

Using the latter resolves the error completely.

Had this same problem and fixed it by setting up AndroidJUnitRunner https://developer.android.com/training/testing/junit-runner.html

For the developer who hasn't used androidx yet. Seeing the LogCat solved the issue for me which was deleting these line running in the wrong thread because of RxJava.

companion object {
    @get:ClassRule @JvmStatic
    val testSchedulerRule = RxImmediateSchedulerRule()
}

In my case it was a StrictMode policy violation caused by AndroidJUnitRunner:

D/StrictMode: StrictMode policy violation: android.os.strictmode.UntaggedSocketViolation: [...]
W/System.err: StrictMode VmPolicy violation with POLICY_DEATH; shutting down.

Disabling the check detectUntaggedSockets() when running an Espresso test fixed it for me. See this question for how to check for that.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!