Failed to resolve variable '${animal.sniffer.version}' when migrate to AndroidX Failed to resolve variable '${animal.sniffer.version}' when migrate to AndroidX android android

Failed to resolve variable '${animal.sniffer.version}' when migrate to AndroidX


I fix this with two steps

1) File -> Invalidate Caches / restart...enter image description here

2) Build -> Clean projectenter image description here


I got the same error after updating my build.gradle file with AndroidX Test dependencies. Turns out I forgot to remove the old junit dependency. So for me, the fix was simply to remove the following dependency:

dependencies {    ...    testImplementation 'junit:junit:4.12'}


Adding Java 8 support to build.gradle file fixed issue for me

android {     ...     //Add the following configuration in order to target Java 8.     compileOptions {         sourceCompatibility JavaVersion.VERSION_1_8         targetCompatibility JavaVersion.VERSION_1_8     }}