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'
try
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
in place of
testInstrumentationRunner 'androidx.test.ext.junit.runners.AndroidJUnit4'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With