1

I've and android studio project which is having following test related dependencies:

implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation fileTree(include: ['*.aar'], dir: 'libs')

// Core library
androidTestImplementation 'androidx.test:core:1.1.0'

// AndroidJUnitRunner and JUnit Rules
androidTestImplementation 'androidx.test:runner:1.1.1'
androidTestImplementation 'androidx.test:rules:1.1.1'

// Assertions
androidTestImplementation 'androidx.test.ext:junit:1.1.0'
androidTestImplementation 'androidx.test.ext:truth:1.1.0'
androidTestImplementation 'com.google.truth:truth:0.42'

// Espresso dependencies
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-contrib:3.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-intents:3.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-accessibility:3.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-web:3.1.1'
androidTestImplementation 'androidx.test.espresso.idling:idling-concurrent:3.1.1'

// The following Espresso dependency can be either "implementation"
// or "androidTestImplementation", depending on whether you want the
// dependency to appear on your APK's compile classpath or the test APK
// classpath.
androidTestImplementation 'androidx.test.espresso:espresso-idling-resource:3.1.1'

Still Android studio fails to import @RunWith annotation. I had the same issue while using API 28 design library of andoridx. I believe androidx still sucks, even when it's asked to developer to use androidx libraries!!

My gradle tool version is '3.3.2' and android studio stable version is 3.3.2

3 Answers 3

1

Are you sure you were in the correct build variant? I had the same issue and switching to the debug build variant let me add the imports correctly

0

Add this dependencies to your build.gradle of app module:

    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'junit:junit:4.12'
0

Add these dependencies:

testImplementation 'junit:junit:4.12'
androidTestImplementation 'junit:junit:4.12'

And make sure you are in the androidTest package and using the debug Build Variant as well

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.