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

32,263

Solution 1

  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

Solution 2

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.

Solution 3

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

Share:
32,263

Related videos on Youtube

paul
Author by

paul

Updated on July 27, 2020

Comments

  • paul
    paul almost 4 years

    My problem seems little different than here Test run failed: Instrumentation run failed due to 'Process crashed.' when testing multiple Android activity
    I have followed steps given in the pdf. I have created test project "TestAndroidCalculatorBlackbox" (do we need to have two project one test and one main project, perhaps this could be the reason, cause in Robotium "Getting Started" link they want us to create projects for Notepad),
    and added jars robotium-solo-5.0.1.jar,robotium-solo-1.6.0.jar, to get rid of red error lines below solo. functions and jay.way package.
    I am attaching the error screenshot: Project tree and error screen shot y AndroidManifest.xml:

    <?xml version="1.0" encoding="utf-8"?>
    <manifest xmlns:android="http://schemas.android.com/apk/res/android"
        package="com.testcalculator"
        android:versionCode="1"
        android:versionName="1.0" >
    
        <uses-sdk android:minSdkVersion="8" />
    
        <instrumentation
            android:name="android.test.InstrumentationTestRunner"
            android:targetPackage="com.testcalculator" />
    
        <application
            android:icon="@drawable/ic_launcher"
            android:label="@string/app_name" android:debuggable="true">
            <uses-library android:name="android.test.runner" />
        </application>
    
    </manifest>
    

    and I have package added in instrumentation list:

     c:\> adb shell pm list instrumentation
    instrumentation:PACKAGE.test.test/android.test.InstrumentationTestRunner (target=PACKAGE)
    instrumentation:PACKAGE.test.test.test.test.test.test/android.test.InstrumentationTestRunner (target=PACKAGE.test.test)
    instrumentation:com.example.android.apis/.app.LocalSampleInstrumentation (target=com.example.android.apis)
    >> instrumentation:com.testcalculator/android.test.InstrumentationTestRunner (target=com.testcalculator) <<
    
  • paul
    paul over 10 years
    Awesome, up-voted!!, I have commented the application part in AndroidManifest.xml. I see the calculator application launched but doesn't execute the test, due to error Test run failed: Instrumentation run failed due to 'java.lang.ClassNotFoundException'. Perhaps the LAUNCHER_ACTIVITY_FULL_CLASSNAME = "com.calculator.Main" is wrong. But I don't know what it should be (I have removed application project and application tag from AndroidManifest.xml )
  • maszter
    maszter over 10 years
    What class is not found? Use LogCat
  • user225405
    user225405 over 5 years
    Awesome! Thanks so much for your comment. Worked for me!
  • Cedulio Cezar
    Cedulio Cezar over 5 years
    Yesterday I left the office thinking about this problem. And today in the morning you have solved for me!! Thank you very much Rowland!
  • Forrest
    Forrest about 4 years
    Excellent. Thank you. Android really should have clearer errors for that! Just lost an hour of work before I found your comment.
  • laim2003
    laim2003 over 3 years
    My LogCat doesn't print anything