java.lang.NoClassDefFoundError: Failed resolution of: Landroid/support/v4/animation/AnimatorCompatHelper


在開發過程中,有的時候引入了多個三方庫.在調用的時候會出現版本對應不上的原因.就會出現如標題的異常。

原因

經過查找,項目中使用的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’


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM