Instrumentation run failed due to 'Process crashed.'

前端 未结 6 1373
感动是毒
感动是毒 2021-02-02 06:12

I wanted to run the following test:

package com.xxx.yyy;

import android.content.Context;
import androidx.test.InstrumentationRegistry;
import androidx.test.runn         


        
相关标签:
6条回答
  • 2021-02-02 06:12
    androidTestImplementation "androidx.test.espresso:espresso-core:3.3.0"
    androidTestImplementation "androidx.test:runner:1.3.0"
    androidTestImplementation "androidx.test:core:1.3.0"
    androidTestImplementation "androidx.test.ext:junit:1.1.2"
    androidTestImplementation "androidx.test:rules:1.3.0"
    

    except for the androidx.test.runner.AndroidJunitRunner config, please also check the dependency. The above code is worked for me.

    0 讨论(0)
  • 2021-02-02 06:21

    I got the error:

    Test running failed: Instrumentation run failed due to 'Process crashed.'
    

    In my case, the android test console only showed the error above without any details.

    But in the logcat, the full error was shown. In my case, I forgot to add the AdMob app_id in AndroidManifest.xml

    So always remember to check the logcat for more error details!

    0 讨论(0)
  • 2021-02-02 06:25

    So I had the same symptoms but after making all these changes I found that the following config in my project build.gradle file that was an issue

    buildTypes{
         debug {
            debuggable true
            minifyEnabled true
            shrinkResources true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    

    seems that minifyEnable and shrinkResources are behaving differently after the upgrade to androidx, could have happened earlier but I just realized it now. Commenting out the lines fixed my No Tests Found Issues.

    buildTypes{
         debug {
            debuggable true
            //minifyEnabled true
            //shrinkResources true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    
    0 讨论(0)
  • 2021-02-02 06:29

    Found the solution by myself. I updated to AndroidX, therefor I needed also to update my build.gradle file from:

    testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    

    to

    testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    
    0 讨论(0)
  • 2021-02-02 06:29

    I got the same error after updating JUnit4 from:

    androidTestImplementation 'junit:junit:4.12
    

    to

    androidTestImplementation 'junit:junit:4.13
    

    The error went away when I downgraded back to:

    androidTestImplementation 'junit:junit:4.12
    
    0 讨论(0)
  • 2021-02-02 06:33

    This error appeared because I changed testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" to testInstrumentationRunner "androidx.test.ext.junit.runners.AndroidJUnit4" in build.gradle. In LogCat I saw:

    java.lang.RuntimeException: Unable to instantiate instrumentation ComponentInfo{com.example.debug.test/androidx.test.ext.junit.runners.AndroidJUnit4}: java.lang.ClassNotFoundException: Didn't find class "androidx.test.ext.junit.runners.AndroidJUnit4" on path: DexPathList[[zip file ...
    
    0 讨论(0)
提交回复
热议问题