BlondeSwan
BlondeSwan

Reputation: 782

Unable to find optional library: android.test.runner

I am attempting to follow android developer documentation's Set up project for AndroidX Test tutorial (found here) but am getting the error unable to find optional library: android.test.runner.

Here is my Gradle file:

...

android {

    ...

    defaultConfig {
        ...

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }

    ...

    useLibrary 'android.test.runner'
    useLibrary 'android.test.base'
    useLibrary 'android.test.mock'

}

...

dependencies {
    ...

    androidTestImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test:core:1.0.0'
    androidTestImplementation 'androidx.test:runner:1.1.0'
    androidTestImplementation 'androidx.test:rules:1.1.0'
    androidTestImplementation 'androidx.test.ext:junit:1.0.0'
    androidTestImplementation 'androidx.test.ext:truth:1.0.0'
    androidTestImplementation 'com.google.truth:truth:0.42'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0'
    androidTestImplementation 'org.hamcrest:hamcrest-library:1.3'
}

As you can see, I have android.test.runner in my dependencies, but when I add the line useLibrary 'android.test.runner' in my android block, I get the error that it can't find that library...

Is there something off with my Gradle file? I'm following the instructions that were outlined on the tutorial, so I don't know what I could possibly be missing...

Upvotes: 3

Views: 1782

Answers (1)

Allen
Allen

Reputation: 3207

I just not added these useless lines and it is still working even if that is in the official guideline.

But if you are migrating the old version to androidx, remember you have to change the compiling version to 28 otherwise will get some errors.

Upvotes: 1

Related Questions