Test Run Failed: Instrumentation Run Failed Due To 'java.lang.ClassNotFoundException'
Solution 1:
I had upgraded to androidx libraries and started getting this error.
To fix it, in build.gradle I changed the line:
testInstrumentationRunner 'android.support.test.runner.AndroidJUnitRunner'
to
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
Solution 2:
FYI I ran into this and had to add
<uses-library android:name="android.test.runner"/>
within my <application/> tag
Solution 3:
In my case, I was trying to run the tests on Jelly Bean emulator. Android instrumentation does not seem to support Jelly Bean. I could run the tests on lollipop.
You may also not able to run android tests through release build type. Ensure that debug build type is active.
Solution 4:
Figured out my issue and am posting the answer for documentation purposes...
The root of my problem was 2 different things:
- I did some refactoring, which change the location of my
android.app.Applicationclass and my activities. This made it so my main program was not working as I needed to update my manifest in myandroid project. - After making the updates to my manifest in my android project, I had to make some updates in my
android test projectto point to the updated location of the class that extendsandroid.app.Application.
After that, did some cleans and tested again and things were good.
Solution 5:
I got the same error because I forgot to add androidx.test:runner test dependency.
androidTestImplementation "androidx.test:runner:1.2.0"
Post a Comment for "Test Run Failed: Instrumentation Run Failed Due To 'java.lang.ClassNotFoundException'"