在開發過程中,有的時候引入了多個三方庫.在調用的時候會出現版本對應不上的原因.就會出現如標題的異常。
原因
經過查找,項目中使用的RecycleView類,進入類里面發現AnimatorCompatHelper缺少引用,使用命令gradlew :app:dependencies查看庫的依賴樹發現RecycleView使用的是25.1.0,而其它support使用的是26.0.1,而導致無法發現AnimatorCompatHelper。
解決辦法
build.gradle里面加入如下代碼塊
configurations.all {
resolutionStrategy.eachDependency { DependencyResolveDetails details ->
def requested = details.requested
if (requested.group == 'com.android.support') {
if (!requested.name.startsWith("multidex")) {
details.useVersion '26.0.1'
}
}
}
}
或者
implementation ‘com.android.support:recyclerview-v7:26.0.1’