Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Problems running tests (<androidx.test.ext.junit.runners.AndroidJUnit4> has no zero argument constructor)

Recently I upgraded my JUnit 4 runner from androidx.test.runner.AndroidJUnit4 to androidx.test.ext.junit.runners.AndroidJUnit4.

When I execute the test i get the following error: Test running failed:

Instrumentation run failed due to 'Process crashed.'

The LogCat shows this error:

java.lang.InstantiationException: 
java.lang.Class<androidx.test.ext.junit.runners.AndroidJUnit4> has no zero argument constructor

All the imports in the test are correct and I'm not getting any error in the build.

My app gradle look like this:

defaultConfig {
        testInstrumentationRunner 'androidx.test.ext.junit.runners.AndroidJUnit4'
    }

implementation fileTree(include: ['*.jar'], dir: 'libs')
    androidTestImplementation "androidx.test.ext:junit:1.1.0"
    androidTestImplementation 'androidx.test:rules:1.1.1'
    androidTestImplementation 'androidx.test:runner:1.1.1'
    androidTestImplementation 'androidx.test.espresso:espresso-intents:3.1.1'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
like image 328
Rafael Álvarez Carranza Avatar asked Feb 14 '19 11:02

Rafael Álvarez Carranza


1 Answers

try

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"

in place of

testInstrumentationRunner 'androidx.test.ext.junit.runners.AndroidJUnit4'
like image 117
iDroid Avatar answered Sep 20 '22 17:09

iDroid